Repository navigation
98 lines (84 loc) · 3.39 KB
/
Copy pathtest.yml
File metadata and controls
98 lines (84 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
name: Test & Verify
on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]
workflow_dispatch:
inputs:
skip_tests:
description: 'Skip running automated tests'
type: boolean
required: false
default: false
permissions:
contents: write
jobs:
test:
name: Build, Test & Publish Worker
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js 22
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Typecheck
run: npm run typecheck
- name: Run test suite
if: |
inputs.skip_tests != true &&
!contains(github.event.head_commit.message, '[skip test]') &&
!contains(github.event.head_commit.message, '[skip tests]') &&
!contains(github.event.head_commit.message, '[skip-test]') &&
!contains(github.event.head_commit.message, '[skip-tests]') &&
!contains(github.event.pull_request.title, '[skip test]') &&
!contains(github.event.pull_request.title, '[skip tests]') &&
!contains(github.event.pull_request.title, '[skip-test]') &&
!contains(github.event.pull_request.title, '[skip-tests]')
run: npm test
- name: Skip tests notice
if: |
inputs.skip_tests == true ||
contains(github.event.head_commit.message, '[skip test]') ||
contains(github.event.head_commit.message, '[skip tests]') ||
contains(github.event.head_commit.message, '[skip-test]') ||
contains(github.event.head_commit.message, '[skip-tests]') ||
contains(github.event.pull_request.title, '[skip test]') ||
contains(github.event.pull_request.title, '[skip tests]') ||
contains(github.event.pull_request.title, '[skip-test]') ||
contains(github.event.pull_request.title, '[skip-tests]')
run: echo "ℹ️ Automated tests skipped via skip flag."
- name: Build CLI and Cloudflare Worker bundles
run: npm run build
- name: Verify CLI executable
run: |
node dist/cli.js --version
node dist/cli.js --help
- name: Verify Cloudflare Worker bundle (global-scope sandbox & handler smoke tests)
run: npm run verify:worker
- name: Upload verified Cloudflare Worker artifact
uses: actions/upload-artifact@v4
with:
name: opencode2api-cloudflare-worker
path: worker/worker.js
if-no-files-found: error
- name: Publish verified worker/worker.js to branch
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add worker/worker.js
if ! git diff --cached --quiet; then
git commit -m "chore(worker): publish verified worker/worker.js bundle [skip ci]"
git push origin "HEAD:${GITHUB_REF_NAME}"
echo "✓ Published updated worker/worker.js to ${GITHUB_REF_NAME}."
else
echo "✓ worker/worker.js is already up to date on ${GITHUB_REF_NAME}."
fi