Skip to content

Commit ffc3cd0

Browse files
committed
upgrade to Workers v4
1 parent 9ac92e4 commit ffc3cd0

File tree

11 files changed

+731
-691
lines changed

11 files changed

+731
-691
lines changed

.github/workflows/checks.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,57 @@ on:
1414
- "rust-toolchain.toml"
1515

1616
jobs:
17-
check:
18-
runs-on: ubuntu-22.04
19-
steps:
20-
- name: Checkout
21-
uses: actions/checkout@v4
22-
- uses: dtolnay/rust-toolchain@stable
23-
- uses: Swatinem/rust-cache@v2
24-
- name: checks
25-
run: |
26-
cargo fmt --all --check
17+
quality-gate:
18+
uses: ./.github/workflows/quality-gate.yml
19+
with:
20+
checks-command: "--all --check"
21+
clippy-command: "-- -D warnings"
22+
tests-command: "test"
2723

2824
deploy:
29-
needs: [check]
30-
runs-on: ubuntu-22.04
25+
needs: [quality-gate]
26+
runs-on: ubuntu-latest
3127
steps:
3228
- name: Checkout
3329
uses: actions/checkout@v4
34-
- uses: dtolnay/rust-toolchain@stable
35-
- uses: Swatinem/rust-cache@v2
36-
- name: Install worker-build
30+
31+
- name: Install nix
32+
uses: nixbuild/nix-quick-install-action@v30
33+
with:
34+
nix_conf: |
35+
keep-env-derivations = true
36+
keep-outputs = true
37+
38+
- name: Restore and save Nix store
39+
uses: nix-community/cache-nix-action@v6
40+
with:
41+
primary-key: build-${{ runner.os }}-${{ hashFiles('**/*.nix', 'flake.lock') }}
42+
restore-prefixes-first-match: build-${{ runner.os }}-
43+
44+
- name: Build nix
45+
run: nix build
46+
47+
- name: Fix up wrangler toml
48+
working-directory: .
3749
run: |
38-
cargo install worker-build
50+
echo "---- Before"
51+
cat wrangler.toml
52+
53+
cat wrangler.toml | sed 's/main = "build/main = "result/' | sed 's/command = "worker-build --release"/command = "echo dummy build"/' >| wrangler.prod.toml
54+
55+
echo "---- After"
56+
cat wrangler.prod.toml
57+
3958
- name: Deploy
4059
uses: cloudflare/wrangler-action@v3
4160
env:
4261
CANGREBOT_API_ENDPOINT: ${{ secrets.CANGREBOT_API_ENDPOINT }}
4362
CANGREBOT_APIKEY: ${{ secrets.CANGREBOT_APIKEY }}
4463
with:
64+
wranglerVersion: "4.19.1"
4565
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
4666
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
67+
command: deploy -c wrangler.prod.toml
4768
secrets: |
4869
CANGREBOT_API_ENDPOINT
4970
CANGREBOT_APIKEY

.github/workflows/quality-gate.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Quality Gate
2+
on:
3+
workflow_call:
4+
inputs:
5+
checks-command:
6+
required: true
7+
type: string
8+
clippy-command:
9+
required: true
10+
type: string
11+
tests-command:
12+
required: true
13+
type: string
14+
workflow_dispatch:
15+
pull_request:
16+
paths:
17+
- "src/**/**.rs"
18+
schedule:
19+
- cron: "0 0 1 * *"
20+
21+
jobs:
22+
quality-gate:
23+
uses: RustLangES/workflows/.github/workflows/quality-gate.yml@main
24+
with:
25+
runs-on: ubuntu-latest
26+
checks-command: ${{ inputs.checks-command }}
27+
clippy-command: ${{ inputs.clippy-command }}
28+
tests-command: ${{ inputs.tests-command }}

0 commit comments

Comments
 (0)