Skip to content

Commit c67ddf0

Browse files
committed
zizmor: Apply more lints
1 parent c5f31b7 commit c67ddf0

File tree

4 files changed

+45
-50
lines changed

4 files changed

+45
-50
lines changed

.github/workflows/ci.yml

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ jobs:
4444
contents: write # for creating branch for pr
4545
pull-requests: write # unused (used in `codegen-automerge: true` case)
4646
security-events: write # for github/codeql-action/*
47-
secrets: inherit
47+
secrets:
48+
PR_TOKEN_APP_PRIVATE_KEY: ${{ secrets.PR_TOKEN_APP_PRIVATE_KEY }}
4849
with:
4950
check-external-types: false
5051
docs: false
@@ -91,9 +92,8 @@ jobs:
9192
- name: Test cargo llvm-cov nextest
9293
run: |
9394
unset RUSTFLAGS
94-
target="${{ matrix.target }}"
95-
if [[ -z "${target}" ]]; then
96-
target=$(rustc -vV | grep -E '^host:' | cut -d' ' -f2)
95+
if [[ -z "${TARGET}" ]]; then
96+
TARGET=$(rustc -vV | grep -E '^host:' | cut -d' ' -f2)
9797
fi
9898
cargo llvm-cov nextest --text --fail-under-lines 50
9999
cargo llvm-cov nextest --text --fail-under-lines 50 --profile default --cargo-profile dev
@@ -116,7 +116,7 @@ jobs:
116116
cargo llvm-cov report --nextest-archive-file a.tar.zst --fail-under-lines 70
117117
cargo clean
118118
rm -- a.tar.zst
119-
cargo llvm-cov nextest-archive --archive-file a.tar.zst --target "${target}"
119+
cargo llvm-cov nextest-archive --archive-file a.tar.zst --target "${TARGET}"
120120
cargo llvm-cov nextest --archive-file a.tar.zst --text --fail-under-lines 70
121121
cargo llvm-cov report --nextest-archive-file a.tar.zst --fail-under-lines 70
122122
cargo clean
@@ -127,6 +127,8 @@ jobs:
127127
cargo llvm-cov nextest --text --fail-under-lines 100 --profile ci
128128
cargo llvm-cov nextest --text --fail-under-lines 100 --profile ci --cargo-profile dev
129129
cargo clean
130+
env:
131+
TARGET: ${{ matrix.target }}
130132
working-directory: tests/fixtures/crates/bin_crate
131133
- name: Test nightly-specific options, old Cargo compatibility
132134
run: |
@@ -141,9 +143,8 @@ jobs:
141143
"$@"
142144
}
143145
unset RUSTFLAGS
144-
target="${{ matrix.target }}"
145-
if [[ -z "${target}" ]]; then
146-
target=$(rustc -vV | grep -E '^host:' | cut -d' ' -f2)
146+
if [[ -z "${TARGET}" ]]; then
147+
TARGET=$(rustc -vV | grep -E '^host:' | cut -d' ' -f2)
147148
fi
148149
149150
# Test nightly-specific options
@@ -164,7 +165,7 @@ jobs:
164165
popd >/dev/null
165166
166167
# Test minimum runnable Cargo version.
167-
case "${{ matrix.target }}" in
168+
case "${TARGET}" in
168169
*-windows-gnullvm) ;; # target unavailable on Rust 1.60.
169170
*)
170171
retry rustup toolchain add 1.60 --no-self-update
@@ -173,6 +174,8 @@ jobs:
173174
popd >/dev/null
174175
;;
175176
esac
177+
env:
178+
TARGET: ${{ matrix.target }}
176179
if: startsWith(matrix.rust, 'nightly')
177180
- name: Test --dep-coverage
178181
run: |
@@ -187,7 +190,7 @@ jobs:
187190
- name: Test show-env --sh on bash
188191
run: |
189192
bash --version
190-
if [[ "${{ matrix.os }}" == "macos"* ]]; then
193+
if [[ "$(uname -s)" == 'Darwin' ]]; then
191194
# macOS's /bin/bash is too old.
192195
cargo llvm-cov show-env --sh > env.sh
193196
# shellcheck disable=SC1091
@@ -479,29 +482,31 @@ jobs:
479482
done
480483
"$@"
481484
}
482-
if type -P clang-"${{ matrix.llvm }}" &>/dev/null; then
485+
if type -P clang-"${LLVM_VERSION}" >/dev/null; then
483486
exit 0
484487
fi
485488
codename=$(grep -E '^VERSION_CODENAME=' /etc/os-release | cut -d= -f2)
486489
sudo mkdir -pm755 -- /etc/apt/keyrings
487490
retry curl --proto '=https' --tlsv1.2 -fsSL https://apt.llvm.org/llvm-snapshot.gpg.key \
488491
| sudo gpg --dearmor -o /etc/apt/keyrings/llvm-snapshot.gpg >/dev/null
489-
sudo tee -- "/etc/apt/sources.list.d/llvm-toolchain-${codename}-${{ matrix.llvm }}.list" >/dev/null \
490-
<<<"deb [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] http://apt.llvm.org/${codename}/ llvm-toolchain-${codename}-${{ matrix.llvm }} main"
492+
sudo tee -- "/etc/apt/sources.list.d/llvm-toolchain-${codename}-${LLVM_VERSION}.list" >/dev/null \
493+
<<<"deb [signed-by=/etc/apt/keyrings/llvm-snapshot.gpg] http://apt.llvm.org/${codename}/ llvm-toolchain-${codename}-${LLVM_VERSION} main"
491494
retry sudo apt-get -o Acquire::Retries=10 -qq update
492495
apt_packages=(
493-
clang-"${{ matrix.llvm }}"
494-
libc++-"${{ matrix.llvm }}"-dev
495-
libc++abi-"${{ matrix.llvm }}"-dev
496-
libclang-"${{ matrix.llvm }}"-dev
497-
lld-"${{ matrix.llvm }}"
498-
llvm-"${{ matrix.llvm }}"
499-
llvm-"${{ matrix.llvm }}"-dev
496+
clang-"${LLVM_VERSION}"
497+
libc++-"${LLVM_VERSION}"-dev
498+
libc++abi-"${LLVM_VERSION}"-dev
499+
libclang-"${LLVM_VERSION}"-dev
500+
lld-"${LLVM_VERSION}"
501+
llvm-"${LLVM_VERSION}"
502+
llvm-"${LLVM_VERSION}"-dev
500503
)
501504
if ! sudo apt-get -o Acquire::Retries=10 -o Dpkg::Use-Pty=0 install -y --no-install-recommends "${apt_packages[@]}"; then
502505
retry sudo apt-get -o Acquire::Retries=10 -o Dpkg::Use-Pty=0 upgrade -y
503506
retry sudo apt-get -o Acquire::Retries=10 -o Dpkg::Use-Pty=0 install -y --no-install-recommends "${apt_packages[@]}"
504507
fi
508+
env:
509+
LLVM_VERSION: ${{ matrix.llvm }}
505510
- run: cargo install --path . --debug
506511
- name: Test
507512
run: |
@@ -515,11 +520,11 @@ jobs:
515520
done
516521
"$@"
517522
}
518-
export CC="clang-${{ matrix.llvm }}"
519-
export CXX="clang++-${{ matrix.llvm }}"
520-
export LLVM_COV="llvm-cov-${{ matrix.llvm }}"
521-
export LLVM_PROFDATA="llvm-profdata-${{ matrix.llvm }}"
522-
case "${{ matrix.llvm }}" in
523+
export CC="clang-${LLVM_VERSION}"
524+
export CXX="clang++-${LLVM_VERSION}"
525+
export LLVM_COV="llvm-cov-${LLVM_VERSION}"
526+
export LLVM_PROFDATA="llvm-profdata-${LLVM_VERSION}"
527+
case "${LLVM_VERSION}" in
523528
1[4-7])
524529
retry rustup toolchain add 1.60 1.65 1.70 1.73 1.77 --no-self-update
525530
cargo clean
@@ -550,4 +555,6 @@ jobs:
550555
cargo +nightly llvm-cov test --text --include-ffi --fail-under-lines 70 -vv
551556
;;
552557
esac
558+
env:
559+
LLVM_VERSION: ${{ matrix.llvm }}
553560
working-directory: tests/fixtures/crates/ffi

.github/workflows/release.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ defaults:
1919
run:
2020
shell: bash --noprofile --norc -CeEuxo pipefail {0}
2121

22+
concurrency:
23+
group: ${{ github.workflow }}
24+
cancel-in-progress: false
25+
2226
jobs:
2327
release:
2428
if: github.repository_owner == 'taiki-e'
@@ -27,7 +31,8 @@ jobs:
2731
contents: write # for taiki-e/create-gh-release-action / taiki-e/upload-rust-binary-action
2832
id-token: write # for rust-lang/crates-io-auth-action / actions/attest
2933
attestations: write # for actions/attest
30-
secrets: inherit
34+
secrets:
35+
PUSH_TOKEN: ${{ secrets.PUSH_TOKEN }}
3136
with:
3237
version: ${{ inputs.version }}
3338
bin: cargo-llvm-cov

.github/zizmor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# https://docs.zizmor.sh/configuration/
33

44
rules:
5-
secrets-inherit: { disable: true }
5+
anonymous-definition: { disable: true }
66
unpinned-uses:
77
config:
88
policies:

tools/tidy.sh

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,6 @@ check_config() {
8686
check_install() {
8787
for tool in "$@"; do
8888
if ! type -P "${tool}" >/dev/null; then
89-
if [[ "${tool}" == 'python3' ]]; then
90-
if type -P python >/dev/null; then
91-
continue
92-
fi
93-
fi
9489
error "'${tool}' is required to run this check"
9590
return 1
9691
fi
@@ -132,10 +127,6 @@ EOF
132127
exit 1
133128
fi
134129

135-
py_suffix=''
136-
if type -P python3 >/dev/null; then
137-
py_suffix=3
138-
fi
139130
yq() { uvx yq "$@"; }
140131
tomlq() { uvx --from yq tomlq "$@"; }
141132
case "$(uname -s)" in
@@ -700,7 +691,7 @@ elif check_install shellcheck; then
700691
# Exclude SC2096 due to the way the temporary script is created.
701692
shellcheck_exclude=SC2096
702693
info "running \`shellcheck --exclude ${shellcheck_exclude}\` for scripts in \`\$(git ls-files '*Dockerfile*')\`"
703-
if check_install jq python3 parse-dockerfile; then
694+
if check_install jq parse-dockerfile; then
704695
shellcheck_for_dockerfile() {
705696
local text=$1
706697
local shell=$2
@@ -833,7 +824,7 @@ elif check_install shellcheck; then
833824
# Exclude SC2096 due to the way the temporary script is created.
834825
shellcheck_exclude=SC2086,SC2096,SC2129
835826
info "running \`shellcheck --exclude ${shellcheck_exclude}\` for scripts in .github/workflows/*.yml and **/action.yml"
836-
if check_install jq python3 uv; then
827+
if check_install jq uv; then
837828
shellcheck_for_gha() {
838829
local text=$1
839830
local shell=$2
@@ -846,16 +837,8 @@ elif check_install shellcheck; then
846837
*) return ;;
847838
esac
848839
text="#!/usr/bin/env ${shell%' {0}'}"$'\n'"${text}"
849-
# Use python because sed doesn't support .*?.
850-
text=$(
851-
"python${py_suffix}" - <<EOF
852-
import re
853-
text = re.sub(r"\\\${{.*?}}", "\${__GHA_SYNTAX__}", r'''${text}''')
854-
print(text)
855-
EOF
856-
)
857840
case "${ostype}" in
858-
windows) text=${text//$'\r'/} ;; # Python print emits \r\n.
841+
windows) text=${text//$'\r'/} ;; # Parse error on git bash/msys2 bash.
859842
esac
860843
local color=auto
861844
if [[ -t 1 ]] || [[ -n "${GITHUB_ACTIONS:-}" ]]; then
@@ -989,11 +972,11 @@ if [[ ${#zizmor_targets[@]} -gt 0 ]]; then
989972
warn "this check is skipped on NetBSD/OpenBSD/Dragonfly/illumos/Solaris due to installing zizmor is hard on these platform"
990973
elif check_install zizmor; then
991974
# zizmor can also be used via uvx, but old version will be installed if glibc version is old.
992-
# Do not use `zizmor -q .` here because it also attempts to check submodules.
975+
# Do not use `zizmor .` here because it also attempts to check submodules.
993976
IFS=' '
994-
info "running \`zizmor -q ${zizmor_targets[*]}\`"
977+
info "running \`zizmor -q --pedantic ${zizmor_targets[*]}\`"
995978
IFS=$'\n\t'
996-
zizmor -q "${zizmor_targets[@]}"
979+
zizmor -q --pedantic "${zizmor_targets[@]}"
997980
fi
998981
fi
999982
printf '\n'

0 commit comments

Comments
 (0)