Skip to content

Commit b3ebb38

Browse files
committed
chore: modernize workflows
1 parent 351c9cd commit b3ebb38

2 files changed

Lines changed: 105 additions & 78 deletions

File tree

.github/workflows/release.yml

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: release
22
permissions:
3-
contents: write
3+
contents: read
44

55
on:
66
push:
@@ -11,7 +11,7 @@ on:
1111
ref_name:
1212
type: string
1313
description: the refname to build a release from
14-
default: "latest"
14+
required: true
1515

1616
concurrency:
1717
group: ${{ github.workflow }}-${{ github.ref }}
@@ -25,33 +25,16 @@ jobs:
2525
name: preflight
2626
runs-on: ubuntu-latest
2727
steps:
28-
- uses: actions/checkout@v4
29-
30-
- name: get stable + nightly Rust
31-
uses: actions-rust-lang/setup-rust-toolchain@v1
32-
with:
33-
toolchain: nightly, stable
34-
target: x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu
35-
components: clippy, rustfmt
36-
cache-directories: |
37-
~/.cargo/registry
38-
~/.cargo/bin
39-
target
40-
41-
- name: consult Clippy
42-
run: cargo +stable clippy --all-targets
43-
44-
- name: check formatting
45-
run: cargo +nightly fmt --check --all
46-
4728
- name: set ref_name
4829
shell: bash
4930
run: |
50-
if [ -n "${{ inputs.ref_name }}" ]; then
51-
echo "REF_NAME=${{ inputs.ref_name }}" >> $GITHUB_ENV
31+
if [ -n "${INPUTS_REF_NAME}" ]; then
32+
echo "REF_NAME=${INPUTS_REF_NAME}" >> $GITHUB_ENV
5233
else
53-
echo "REF_NAME=${{ github.ref_name }}" >> $GITHUB_ENV
34+
echo "REF_NAME=${GITHUB_REF_NAME}" >> $GITHUB_ENV
5435
fi
36+
env:
37+
INPUTS_REF_NAME: ${{ inputs.ref_name }}
5538

5639
- name: create github release
5740
continue-on-error: true # for testing
@@ -64,26 +47,32 @@ jobs:
6447
name: release-linux
6548
runs-on: ubuntu-latest
6649
needs: preflight
50+
permissions:
51+
contents: write
6752
steps:
68-
- uses: actions/checkout@v4
53+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
54+
with:
55+
persist-credentials: false
6956

7057
- name: get stable Rust
71-
uses: actions-rust-lang/setup-rust-toolchain@v1
58+
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1
7259
with:
7360
toolchain: stable
7461
cache-directories: |
7562
~/.cargo/registry
7663
~/.cargo/bin
7764
target
65+
cache: false
7866

7967
- name: build for release and upload
8068
env:
8169
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8270
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
INPUTS_REF_NAME: ${{ inputs.ref_name }}
8372
run: |
84-
REF_NAME="${{ github.ref_name }}"
85-
if [ -n "${{ inputs.ref_name }}" ]; then
86-
REF_NAME="${{ inputs.ref_name }}"
73+
REF_NAME="${GITHUB_REF_NAME}"
74+
if [ -n "${INPUTS_REF_NAME}" ]; then
75+
REF_NAME="${INPUTS_REF_NAME}"
8776
fi
8877
cargo +stable build --release
8978
tar czf tomato-x86_64-unknown-linux-gnu.tar.gz --strip-components=2 target/release/tomato
@@ -93,18 +82,23 @@ jobs:
9382
name: release-macos
9483
runs-on: macos-latest
9584
needs: preflight
85+
permissions:
86+
contents: write
9687
steps:
97-
- uses: actions/checkout@v4
88+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
89+
with:
90+
persist-credentials: false
9891

9992
- name: get stable Rust
100-
uses: actions-rust-lang/setup-rust-toolchain@v1
93+
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1
10194
with:
10295
toolchain: stable
10396
target: aarch64-apple-darwin, x86_64-apple-darwin
10497
cache-directories: |
10598
~/.cargo/registry
10699
~/.cargo/bin
107100
target
101+
cache: false
108102

109103
- name: build for release
110104
run: |
@@ -114,10 +108,11 @@ jobs:
114108
- name: upload release assets
115109
env:
116110
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
111+
INPUTS_REF_NAME: ${{ inputs.ref_name }}
117112
run: |
118-
REF_NAME="${{ github.ref_name }}"
119-
if [ -n "${{ inputs.ref_name }}" ]; then
120-
REF_NAME="${{ inputs.ref_name }}"
113+
REF_NAME="${GITHUB_REF_NAME}"
114+
if [ -n "${INPUTS_REF_NAME}" ]; then
115+
REF_NAME="${INPUTS_REF_NAME}"
121116
fi
122117
mkdir -p dist
123118
cd dist
@@ -129,11 +124,15 @@ jobs:
129124
postflight:
130125
name: postflight
131126
runs-on: ubuntu-latest
127+
permissions:
128+
contents: write
132129
needs:
133130
- release-linux
134131
- release-macos
135132
steps:
136-
- uses: actions/checkout@v4
133+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
134+
with:
135+
persist-credentials: false
137136

138137
- name: get formulaic on path
139138
shell: bash
@@ -144,11 +143,13 @@ jobs:
144143
- name: set ref_name
145144
shell: bash
146145
run: |
147-
if [ -n "${{ inputs.ref_name }}" ]; then
148-
echo "REF_NAME=${{ inputs.ref_name }}" >> $GITHUB_ENV
146+
if [ -n "${INPUTS_REF_NAME}" ]; then
147+
echo "REF_NAME=${INPUTS_REF_NAME}" >> $GITHUB_ENV
149148
else
150-
echo "REF_NAME=${{ github.ref_name }}" >> $GITHUB_ENV
149+
echo "REF_NAME=${GITHUB_REF_NAME}" >> $GITHUB_ENV
151150
fi
151+
env:
152+
INPUTS_REF_NAME: ${{ inputs.ref_name }}
152153

153154
- name: publish the draft release
154155
env:

.github/workflows/test.yaml

Lines changed: 66 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,72 @@
11
name: "Tests"
22
on:
3-
push:
4-
branches: [ "latest" ]
5-
paths:
6-
- src/**
7-
- fixtures/**
8-
- Cargo.toml
9-
- Cargo.lock
10-
- .github/workflows/test.yaml
11-
pull_request:
12-
branches: [ "latest" ]
13-
workflow_dispatch:
3+
push:
4+
branches: [ "latest" ]
5+
paths:
6+
- src/**
7+
- fixtures/**
8+
- Cargo.toml
9+
- Cargo.lock
10+
- .github/workflows/test.yaml
11+
pull_request:
12+
branches: [ "latest" ]
13+
workflow_dispatch:
14+
permissions:
15+
contents: read
1416

1517
env:
16-
CARGO_TERM_COLOR: always
18+
CARGO_TERM_COLOR: always
19+
SCCACHE_GHA_ENABLED: "true"
20+
RUSTC_WRAPPER: "sccache"
1721

1822
jobs:
19-
test:
20-
name: test
21-
runs-on: ubuntu-latest
22-
steps:
23-
- uses: actions/checkout@v3
24-
- uses: actions-rs/toolchain@v1
25-
with:
26-
toolchain: stable
27-
override: true
28-
29-
- uses: actions/cache@v3
30-
with:
31-
path: |
32-
~/.cargo/registry
33-
~/.cargo/git
34-
target
35-
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
36-
restore-keys: |
37-
${{ runner.os }}-cargo-
38-
39-
- name: get cargo-nextest on path
40-
run: |
41-
curl -sL https://get.nexte.st/latest/linux -o nextest.tgz
42-
tar xfz nextest.tgz
43-
mv cargo-nextest /home/runner/.cargo/bin
44-
45-
- name: run the tests
46-
run: cargo nextest run
23+
test:
24+
name: test
25+
runs-on: ubuntu-latest
26+
steps:
27+
- name: checkout
28+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
29+
with:
30+
persist-credentials: false
31+
32+
- name: sccache-cache
33+
uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696
34+
35+
- name: get stable Rust
36+
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1
37+
with:
38+
toolchain: stable
39+
cache-directories: |
40+
~/.cargo/registry
41+
~/.cargo/bin
42+
target
43+
44+
- name: get cargo-nextest on path
45+
run: |
46+
curl -sL https://get.nexte.st/latest/linux -o nextest.tgz
47+
tar xfz nextest.tgz
48+
mv cargo-nextest /home/runner/.cargo/bin
49+
50+
- name: run the tests
51+
run: cargo nextest run
52+
53+
fmt:
54+
name: formatting check
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: checkout
58+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
59+
with:
60+
persist-credentials: false
61+
62+
- name: sccache-cache
63+
uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696
64+
65+
- name: Install nightly Rust
66+
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6
67+
with:
68+
toolchain: nightly
69+
components: rustfmt
70+
71+
- name: check formatting
72+
run: cargo +nightly fmt --check --all

0 commit comments

Comments
 (0)