Skip to content

Commit 4d46c8e

Browse files
authored
feat: use Deno more extensively in CI (#54)
* chore: add @actions/core to interface with GitHub Actions * feat(infra/actions): add initial deno script * ci(infra/actions): add deno CI test run action * ci: ensure test run ci only runs in the current branch * refactor(infra/actions): try CI detection * refactor(infra/actions): fix CI detection to actually choose a branch, and also inspect the CI variable * feat(scripts/ci): add new workflow API * chore(config/deno): add ci permission set * chore(deps): update lockfile * Revert "feat(scripts/ci): add new workflow API" This reverts commit f11e033. * feat(scripts/ci): achieve near-feature-parity with original CI workflow * ci(scripts/ci): ensure script is run with correct permissions * fix(scripts/ci): ensure width is always calculated, even in CI * refactor(scripts/ci): move common command options to one dedicated object * chore(deps): add @std/async * fix(scripts/ci): wait a bit to go to the next command's output in CI * ci(infra/actions): remove test run action * ci(infra/actions): add main ci reusable workflow * ci(infra/actions): use new reusable workflow to greatly simplify ci * ci(infra/actions): add name to workflow call * ci(infra/actions): rename job Rename job for easier time finding in branch protection rules * chore(deps): add @actions/github * ci(scripts/clean-up-caches): add @encode/clean-up-caches * ci(actions/clean-up-caches): add action to clean caches * ci(actions/clean-up-caches): fix insufficient permissions * ci(@encode/clean-up-caches): use Deno env instead of GitHub inputs * ci(actions/clean-up-caches): pass in token as env var * ci(actions/clean-up-caches): add permissions * ci(actions/clean-up-caches): add permissions everywhere needed * ci(actions/clean-up-caches): remove actions/clean-up-caches
1 parent 8e72e4d commit 4d46c8e

7 files changed

Lines changed: 341 additions & 91 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -4,91 +4,9 @@ on:
44
push:
55
pull_request:
66

7-
env:
8-
# Used to differentiate from other slices of the cache for other workflow runs, and to forcefully bust the cache when renamed
9-
CACHE_KEY_BASE: ci@v1
10-
117
jobs:
12-
setup:
13-
name: Setup
14-
runs-on: ubuntu-latest
15-
steps:
16-
- name: Checkout repository
17-
uses: actions/checkout@v5
18-
19-
- name: Set up Deno
20-
uses: denoland/setup-deno@v2
21-
with:
22-
deno-version: 2.x
23-
cache-hash: ${{ env.CACHE_KEY_BASE }}-${{ hashFiles('deno.lock') }}
24-
25-
- name: Install dependencies
26-
run: deno install
27-
28-
test:
29-
name: Test
30-
needs: [setup]
31-
runs-on: ubuntu-latest
32-
steps:
33-
- name: Checkout repository
34-
uses: actions/checkout@v5
35-
36-
# Now the Deno cache should be warmed up, so this should be much faster
37-
- name: Set up Deno
38-
uses: denoland/setup-deno@v2
39-
with:
40-
deno-version: 2.x
41-
cache-hash: ${{ env.CACHE_KEY_BASE }}-${{ hashFiles('deno.lock') }}
42-
43-
- name: Test
44-
run: deno test -P --no-prompt --coverage --shuffle
45-
46-
- name: Upload coverage report
47-
uses: actions/upload-artifact@v4
48-
with:
49-
name: coverage-report
50-
path: |
51-
coverage/html
52-
coverage/lcov.info
53-
54-
- name: Upload raw coverage files
55-
uses: actions/upload-artifact@v4
56-
with:
57-
name: coverage-report-raw
58-
path: coverage/*.json
59-
60-
lint:
61-
name: Lint
62-
needs: [setup]
63-
runs-on: ubuntu-latest
64-
steps:
65-
- name: Checkout repository
66-
uses: actions/checkout@v5
67-
68-
# Now the Deno cache should be warmed up, so this should be much faster
69-
- name: Set up Deno
70-
uses: denoland/setup-deno@v2
71-
with:
72-
deno-version: 2.x
73-
cache-hash: ${{ env.CACHE_KEY_BASE }}-${{ hashFiles('deno.lock') }}
74-
75-
- name: Lint
76-
run: deno run --allow-env --allow-run --no-prompt npm:@biomejs/biome ci
77-
78-
check:
79-
name: Check
80-
needs: [setup]
81-
runs-on: ubuntu-latest
82-
steps:
83-
- name: Checkout repository
84-
uses: actions/checkout@v5
85-
86-
# Now the Deno cache should be warmed up, so this should be much faster
87-
- name: Set up Deno
88-
uses: denoland/setup-deno@v2
89-
with:
90-
deno-version: 2.x
91-
cache-hash: ${{ env.CACHE_KEY_BASE }}-${{ hashFiles('deno.lock') }}
92-
93-
- name: Lint
94-
run: deno check
8+
run-procedure:
9+
name: Run CI Procedure
10+
uses: ./.github/workflows/fn-ci.yml
11+
with:
12+
cache-key-base: ci@v1

.github/workflows/fn-ci.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: CI Procedure
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
cache-key-base:
7+
description: A string used to differentiate from other slices of the cache for other workflow runs, and to forcefully bust the cache when renamed
8+
type: string
9+
required: true
10+
11+
jobs:
12+
main-checks:
13+
name: Main Checks
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v5
18+
19+
- name: Set up Deno
20+
uses: denoland/setup-deno@v2
21+
with:
22+
deno-version: 2.x
23+
cache-hash: ${{ inputs.cache-key-base }}-${{ hashFiles('deno.lock') }}
24+
25+
- name: Install dependencies
26+
run: deno install
27+
28+
- name: Run main script
29+
run: deno run -P=ci @encode/ci
30+
31+
- name: Upload coverage report
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: coverage-report
35+
path: |
36+
coverage/html
37+
coverage/lcov.info
38+
39+
- name: Upload raw coverage files
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: coverage-report-raw
43+
path: coverage/*.json

deno.jsonc

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@
88
},
99

1010
"imports": {
11-
// Import alias
12-
"@root/": "./",
13-
// External dependencies
11+
"@actions/core": "npm:@actions/core@^1.11.1",
12+
"@actions/github": "npm:@actions/github@^6.0.1",
1413
"@biomejs/biome": "npm:@biomejs/biome@2.3.6",
1514
"@std/assert": "jsr:@std/assert@1.0.16",
15+
"@std/async": "jsr:@std/async@^1.0.15",
1616
"@std/testing": "jsr:@std/testing@1.0.16",
1717
"@std/fmt": "jsr:@std/fmt@1.0.8",
1818
"@std/cli": "jsr:@std/cli@1.0.24",
1919
"@std/fs": "jsr:@std/fs@1.0.20",
2020
"@std/path": "jsr:@std/path@1.1.3",
21-
"chevrotain": "npm:chevrotain@^11.0.3"
21+
"chevrotain": "npm:chevrotain@^11.0.3",
22+
23+
"@root/": "./"
2224
},
2325

2426
"test": {
@@ -31,6 +33,11 @@
3133
"biome": {
3234
"env": true,
3335
"run": true
36+
},
37+
38+
"ci": {
39+
"env": true,
40+
"run": ["deno"]
3441
}
3542
},
3643

0 commit comments

Comments
 (0)