Skip to content

Commit 05f3825

Browse files
committed
ci,tools: Update config and script
1 parent 96b8d5f commit 05f3825

4 files changed

Lines changed: 54 additions & 18 deletions

File tree

.github/dependabot.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ updates:
1212
- package-ecosystem: github-actions
1313
directory: /
1414
schedule:
15-
interval: weekly
15+
interval: monthly
1616
cooldown:
1717
default-days: 14
1818
commit-message:

.github/workflows/ci.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: CI
22

3-
permissions:
4-
contents: read
3+
permissions: {}
54

65
on:
76
pull_request:
@@ -34,15 +33,15 @@ concurrency:
3433

3534
jobs:
3635
miri:
37-
uses: taiki-e/github-actions/.github/workflows/miri.yml@dec917193d835117a7238865adf83273d9fcd27a # main
36+
uses: taiki-e/github-actions/.github/workflows/miri.yml@68753a4331ec78cb842512fd16ae32da0c066e31 # main
3837
msrv:
39-
uses: taiki-e/github-actions/.github/workflows/msrv.yml@dec917193d835117a7238865adf83273d9fcd27a # main
38+
uses: taiki-e/github-actions/.github/workflows/msrv.yml@68753a4331ec78cb842512fd16ae32da0c066e31 # main
4039
test:
41-
uses: taiki-e/github-actions/.github/workflows/test.yml@dec917193d835117a7238865adf83273d9fcd27a # main
40+
uses: taiki-e/github-actions/.github/workflows/test.yml@68753a4331ec78cb842512fd16ae32da0c066e31 # main
4241
with:
4342
rust: 1.71,stable,beta,nightly
4443
tidy:
45-
uses: taiki-e/github-actions/.github/workflows/tidy.yml@dec917193d835117a7238865adf83273d9fcd27a # main
44+
uses: taiki-e/github-actions/.github/workflows/tidy.yml@68753a4331ec78cb842512fd16ae32da0c066e31 # main
4645
permissions:
4746
contents: write # for creating branch for pr
4847
pull-requests: write # unused (used in `codegen-automerge: true` case)
@@ -51,11 +50,11 @@ jobs:
5150
PR_TOKEN_APP_PRIVATE_KEY: ${{ secrets.PR_TOKEN_APP_PRIVATE_KEY }}
5251

5352
no-std:
54-
runs-on: ubuntu-latest
53+
runs-on: ubuntu-24.04
5554
timeout-minutes: 60
5655
steps:
5756
- uses: taiki-e/checkout-action@7d1e50e93dc4fb3bba58f85018fadf77898aee8b # v1.4.2
58-
- uses: taiki-e/github-actions/install-rust@dec917193d835117a7238865adf83273d9fcd27a # main # zizmor: ignore[stale-action-refs]
57+
- uses: taiki-e/github-actions/install-rust@68753a4331ec78cb842512fd16ae32da0c066e31 # main # zizmor: ignore[stale-action-refs]
5958
with:
6059
toolchain: nightly
6160
target: thumbv6m-none-eabi

.github/workflows/release.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
name: Release
22

3-
permissions:
4-
contents: read
3+
permissions: {}
54

65
on:
76
workflow_dispatch:
@@ -26,7 +25,7 @@ concurrency:
2625
jobs:
2726
release:
2827
if: github.repository_owner == 'taiki-e'
29-
uses: taiki-e/github-actions/.github/workflows/rust-release.yml@dec917193d835117a7238865adf83273d9fcd27a # main
28+
uses: taiki-e/github-actions/.github/workflows/rust-release.yml@68753a4331ec78cb842512fd16ae32da0c066e31 # main
3029
permissions:
3130
contents: write # for taiki-e/create-gh-release-action
3231
id-token: write # for rust-lang/crates-io-auth-action

tools/tidy.sh

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,22 @@ cd -- "$(dirname -- "$0")"/..
99
# GITHUB_TOKEN=$(gh auth token) ./tools/tidy.sh
1010
#
1111
# Note: This script requires the following tools:
12-
# - docker
12+
# - docker or podman (or compatible CLI specified by TIDY_DOCKER_PATH. when both available and TIDY_DOCKER_PATH is not set, docker is preferred)
1313
#
1414
# This script is shared by projects under github.com/taiki-e, so there may also
1515
# be checks for files not included in this repository, but they will be skipped
1616
# if the corresponding files do not exist.
1717
# It is not intended for manual editing.
1818

19+
bail() {
20+
if [[ -n "${GITHUB_ACTIONS:-}" ]]; then
21+
printf '::error::%s\n' "$*"
22+
else
23+
printf >&2 'error: %s\n' "$*"
24+
fi
25+
exit 1
26+
}
27+
1928
if [[ $# -gt 0 ]]; then
2029
cat <<EOF
2130
USAGE:
@@ -24,24 +33,29 @@ EOF
2433
exit 1
2534
fi
2635

36+
image='ghcr.io/taiki-e/tidy'
2737
if [[ -n "${TIDY_DEV:-}" ]]; then
28-
image="ghcr.io/taiki-e/tidy:latest"
38+
image+=':latest'
2939
else
30-
image="ghcr.io/taiki-e/tidy@sha256:bce85a4321f80c09f2b68420e9149bcf7c085130ab1e1fca54443f76833cd184"
40+
image+='@sha256:4d7ec52a86bd3c0a2d96627b0ec3aa534afc02c2d56fc9a898df64e29aa03312'
3141
fi
3242
user="$(id -u):$(id -g)"
3343
workdir=$(pwd)
3444
tmp=$(mktemp -d)
3545
trap -- 'rm -rf -- "${tmp:?}"' EXIT
3646
mkdir -p -- "${tmp}"/{pwsh-cache,pwsh-local,zizmor-cache,dummy-dir,tmp}
37-
touch -- "${tmp}"/dummy
47+
printf '' >"${tmp}"/dummy
3848
code=0
3949
color=''
4050
if [[ -t 1 ]] || [[ -n "${GITHUB_ACTIONS:-}" ]]; then
4151
color=1
4252
fi
53+
# Refs:
54+
# - https://docs.docker.com/reference/cli/docker/container/run/
55+
# - https://docs.podman.io/en/latest/markdown/podman-run.1.html
56+
# - https://cheatsheetseries.owasp.org/cheatsheets/Docker_Security_Cheat_Sheet.html
4357
common_args=(
44-
run --rm --init -i --user "${user}"
58+
run --rm --init
4559
--cap-drop=all
4660
--security-opt=no-new-privileges
4761
--read-only
@@ -59,6 +73,30 @@ common_args=(
5973
--env TIDY_EXPECTED_SHELL_FILE_COUNT
6074
--env TIDY_EXPECTED_DOCKER_FILE_COUNT
6175
)
76+
if [[ -n "${TIDY_DOCKER_PATH:-}" ]]; then
77+
docker="${TIDY_DOCKER_PATH}"
78+
elif type -P docker >/dev/null; then
79+
docker='docker'
80+
elif type -P podman >/dev/null; then
81+
docker='podman'
82+
else
83+
bail 'this script requires docker or podman'
84+
fi
85+
rootless=''
86+
if [[ "$("${docker}" --version)" == *'podman'* ]]; then
87+
if [[ "$("${docker}" info)" == *'rootless: true'* ]]; then
88+
rootless=1
89+
fi
90+
elif [[ "$("${docker}" info -f '{{println .SecurityOptions}}')" == *'rootless'* ]]; then
91+
rootless=1
92+
fi
93+
if [[ -n "${rootless}" ]]; then
94+
printf 'docker path: %s\n' "${docker} (rootless)"
95+
else
96+
printf 'docker path: %s\n' "${docker}"
97+
common_args+=(--user "${user}")
98+
fi
99+
62100
# Map ignored files (e.g., .env) to dummy files.
63101
while IFS= read -r path; do
64102
if [[ -d "${path}" ]]; then
@@ -73,7 +111,7 @@ while IFS= read -r path; do
73111
done < <(git status --porcelain --ignored | grep -E '^!!' | cut -d' ' -f2)
74112

75113
docker_run() {
76-
docker "${common_args[@]}" "$@"
114+
"${docker}" "${common_args[@]}" "$@"
77115
code2="$?"
78116
if [[ ${code} -eq 0 ]] && [[ ${code2} -ne 0 ]]; then
79117
code="${code2}"

0 commit comments

Comments
 (0)