Skip to content

Commit 569ac11

Browse files
committed
converted actionlint github workflow test to rust test
1 parent 13ad27f commit 569ac11

File tree

2 files changed

+31
-44
lines changed
  • .github/workflows
  • test-fuzz/tests/integration

2 files changed

+31
-44
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,18 @@ env:
1919
CARGO_TERM_COLOR: always
2020

2121
jobs:
22-
maybe-expedite:
22+
check-up-to-dateness:
2323
outputs:
24-
value: ${{ steps.expedite.outputs.value }}
25-
24+
is-up-to-date: ${{ steps.main.outputs.is-up-to-date }}
2625
runs-on: ubuntu-latest
27-
2826
steps:
29-
- name: Log github refs
30-
run: |
31-
echo '```' >> "$GITHUB_STEP_SUMMARY"
32-
echo 'github.ref: ${{ github.ref }}' >> "$GITHUB_STEP_SUMMARY"
33-
echo 'github.sha: ${{ github.sha }}' >> "$GITHUB_STEP_SUMMARY"
34-
echo '```' >> "$GITHUB_STEP_SUMMARY"
35-
36-
- uses: actions/checkout@v4
37-
with:
38-
fetch-depth: 0
39-
40-
- name: Check if merging an up-to-date branch
41-
if: ${{ github.event_name == 'merge_group' }}
42-
id: expedite
43-
run: |
44-
N="$(expr "${{ github.ref }}" : '.*-\([0-9]\+\)-[^-]*$')"
45-
BASE_SHA="$(gh api /repos/${{ github.repository }}/pulls/"$N" | jq -r '.base.sha')"
46-
if git diff --quiet ${{ github.event.merge_group.base_sha }} "$BASE_SHA"; then
47-
echo "value=1" >> "$GITHUB_OUTPUT"
48-
fi
49-
env:
50-
GH_TOKEN: ${{ github.token }}
27+
- id: main
28+
uses: trailofbits/check-up-to-dateness@v1
5129

5230
lint:
53-
needs: [maybe-expedite]
31+
needs: [check-up-to-dateness]
5432

55-
if: ${{ ! needs.maybe-expedite.outputs.value }}
33+
if: needs.check-up-to-dateness.outputs.is-up-to-date != 'true'
5634

5735
runs-on: ubuntu-latest
5836

@@ -90,22 +68,10 @@ jobs:
9068
- name: Prettier
9169
run: npm install -g prettier && prettier --check '**/*.json' '**/*.md' '**/*.yml'
9270

93-
# https://github.com/DevinR528/cargo-sort/issues/57#issuecomment-1457714872
94-
- name: Cargo sort
95-
run: |
96-
cargo install cargo-sort || true
97-
find . -name Cargo.toml -print0 | xargs -0 -n 1 dirname | xargs -n 1 cargo sort --check --grouped --no-format
98-
99-
- name: Format
100-
run: |
101-
rustup install nightly
102-
rustup +nightly component add rustfmt
103-
cargo +nightly fmt && git diff --exit-code
104-
10571
test:
106-
needs: [maybe-expedite]
72+
needs: [check-up-to-dateness]
10773

108-
if: ${{ ! needs.maybe-expedite.outputs.value }}
74+
if: needs.check-up-to-dateness.outputs.is-up-to-date != 'true'
10975

11076
runs-on: ubuntu-latest
11177

@@ -156,12 +122,14 @@ jobs:
156122
run: |
157123
rustup install nightly
158124
rustup +nightly component add clippy
125+
rustup +nightly component add rustfmt
159126
cargo install cargo-dylint dylint-link || true
160127
cargo install cargo-license || true
161128
cargo install cargo-sort || true
162129
cargo install cargo-supply-chain || true
163130
cargo install cargo-unmaintained || true
164131
cargo install group-runner || true
132+
go install github.com/rhysd/actionlint/cmd/actionlint@latest
165133
166134
- name: Free up space
167135
run: |

test-fuzz/tests/integration/ci.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use regex::Regex;
33
use similar_asserts::SimpleDiff;
44
use std::{
55
collections::HashSet,
6-
env::var,
6+
env,
77
ffi::OsStr,
88
fs::{read_to_string, write},
99
path::Path,
@@ -22,6 +22,15 @@ fn clippy() {
2222
.success();
2323
}
2424

25+
#[test]
26+
fn format() {
27+
Command::new("cargo")
28+
.args(["+nightly", "fmt", "--check"])
29+
.current_dir("..")
30+
.logged_assert()
31+
.success();
32+
}
33+
2534
#[test]
2635
fn dylint() {
2736
Command::new("cargo")
@@ -223,7 +232,17 @@ fn unmaintained() {
223232
.success();
224233
}
225234

235+
#[test]
236+
fn actionlint() {
237+
#[allow(deprecated)]
238+
let home = env::home_dir().unwrap();
239+
Command::new(home.join("go/bin/actionlint"))
240+
.env("SHELLCHECK_OPTS", "--exclude=SC2002")
241+
.logged_assert()
242+
.success();
243+
}
244+
226245
#[must_use]
227246
pub fn enabled(key: &str) -> bool {
228-
var(key).is_ok_and(|value| value != "0")
247+
env::var(key).is_ok_and(|value| value != "0")
229248
}

0 commit comments

Comments
 (0)