From ab8aac3cf920603bda7b6c7ce93b45e7c2941695 Mon Sep 17 00:00:00 2001 From: Oliver Gould Date: Wed, 17 Aug 2022 07:18:42 -0700 Subject: [PATCH] dev: Use a common action-dev-check (#1895) This change updates to the v28 devcontainer, which includes an extracted `action-dev-check` script that replaces the inlined just recipe. This change also renames some recipes (like action-lint, md-lint, and sh-lint) to be uniform with the recipes in other repos. Signed-off-by: Oliver Gould Signed-off-by: Oliver Gould --- .devcontainer/devcontainer.json | 2 +- .../actions/list-changed-crates/Dockerfile | 2 +- .github/workflows/actions.yml | 8 +- .github/workflows/beta.yml | 2 +- .github/workflows/check-all.yml | 2 +- .github/workflows/check-each.yml | 2 +- .github/workflows/coverage.yml | 2 +- .github/workflows/deps.yml | 2 +- .github/workflows/integration.yml | 2 +- .github/workflows/lint.yml | 6 +- .github/workflows/nightly.yml | 2 +- .github/workflows/shellcheck.yml | 9 ++- .github/workflows/test.yml | 4 +- .github/workflows/toolchain.yml | 4 +- justfile | 75 ++++--------------- 15 files changed, 40 insertions(+), 84 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 6827ae0e9..ecf380454 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,6 +1,6 @@ { "name": "linkerd2-proxy", - "image": "ghcr.io/linkerd/dev:v26", + "image": "ghcr.io/linkerd/dev:v28", "extensions": [ "DavidAnson.vscode-markdownlint", "kokakiwi.vscode-just", diff --git a/.github/actions/list-changed-crates/Dockerfile b/.github/actions/list-changed-crates/Dockerfile index 4cfb5c517..53a7b4a79 100644 --- a/.github/actions/list-changed-crates/Dockerfile +++ b/.github/actions/list-changed-crates/Dockerfile @@ -1,3 +1,3 @@ -FROM ghcr.io/linkerd/dev:v26-rust +FROM ghcr.io/linkerd/dev:v28-rust COPY entrypoint.sh / ENTRYPOINT ["/entrypoint.sh"] diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 7d51d647a..80d366627 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -13,14 +13,14 @@ jobs: actionlint: runs-on: ubuntu-20.04 timeout-minutes: 10 - container: ghcr.io/linkerd/dev:v26-tools + container: ghcr.io/linkerd/dev:v28-tools steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - - run: just actions-lint + - run: just action-lint devcontainer-versions: runs-on: ubuntu-latest - container: ghcr.io/linkerd/dev:v26-tools + container: ghcr.io/linkerd/dev:v28-tools steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - - run: just actions-dev-versions + - run: just action-dev-check diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml index 9d3d84e3c..6d0cc0452 100644 --- a/.github/workflows/beta.yml +++ b/.github/workflows/beta.yml @@ -22,7 +22,7 @@ permissions: jobs: build: runs-on: ubuntu-latest - container: ghcr.io/linkerd/dev:v26-rust + container: ghcr.io/linkerd/dev:v28-rust timeout-minutes: 20 continue-on-error: true steps: diff --git a/.github/workflows/check-all.yml b/.github/workflows/check-all.yml index f663d2f15..f44d06dcb 100644 --- a/.github/workflows/check-all.yml +++ b/.github/workflows/check-all.yml @@ -25,7 +25,7 @@ jobs: check-all: timeout-minutes: 20 runs-on: ubuntu-latest - container: ghcr.io/linkerd/dev:v26-rust + container: ghcr.io/linkerd/dev:v28-rust steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - run: just fetch diff --git a/.github/workflows/check-each.yml b/.github/workflows/check-each.yml index 54709af04..f238140b2 100644 --- a/.github/workflows/check-each.yml +++ b/.github/workflows/check-each.yml @@ -49,7 +49,7 @@ jobs: needs: list-changed-crates timeout-minutes: 20 runs-on: ubuntu-latest - container: ghcr.io/linkerd/dev:v26-rust + container: ghcr.io/linkerd/dev:v28-rust strategy: matrix: crate: ${{ fromJson(needs.list-changed-crates.outputs.crates) }} diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index dc98fe7b0..a439b78ad 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 30 container: - image: docker://ghcr.io/linkerd/dev:v26-rust + image: docker://ghcr.io/linkerd/dev:v28-rust options: --security-opt seccomp=unconfined # 🤷 steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b diff --git a/.github/workflows/deps.yml b/.github/workflows/deps.yml index b6f5a95b6..0b61ed861 100644 --- a/.github/workflows/deps.yml +++ b/.github/workflows/deps.yml @@ -46,7 +46,7 @@ jobs: deprecated: timeout-minutes: 20 runs-on: ubuntu-latest - container: ghcr.io/linkerd/dev:v26-rust + container: ghcr.io/linkerd/dev:v28-rust steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - run: just fetch diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 8d02c41fd..0c572a407 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -26,7 +26,7 @@ jobs: test: timeout-minutes: 20 runs-on: ubuntu-latest - container: ghcr.io/linkerd/dev:v26-rust + container: ghcr.io/linkerd/dev:v28-rust steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - run: just fetch diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cd4223cc6..4ac51d454 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,7 +21,7 @@ jobs: clippy: timeout-minutes: 10 runs-on: ubuntu-latest - container: ghcr.io/linkerd/dev:v26-rust + container: ghcr.io/linkerd/dev:v28-rust steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - run: just fetch @@ -30,7 +30,7 @@ jobs: fmt: timeout-minutes: 10 runs-on: ubuntu-latest - container: ghcr.io/linkerd/dev:v26-rust + container: ghcr.io/linkerd/dev:v28-rust steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - run: just check-fmt @@ -38,7 +38,7 @@ jobs: docs: timeout-minutes: 10 runs-on: ubuntu-latest - container: ghcr.io/linkerd/dev:v26-rust + container: ghcr.io/linkerd/dev:v28-rust steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - run: just fetch diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 4bba27188..ab492daec 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -22,7 +22,7 @@ permissions: jobs: build: runs-on: ubuntu-latest - container: ghcr.io/linkerd/dev:v26-rust + container: ghcr.io/linkerd/dev:v28-rust timeout-minutes: 20 continue-on-error: true steps: diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index 5da1070da..353df31c3 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -6,14 +6,15 @@ permissions: on: pull_request: paths: - - '**/*.sh' - .github/workflows/shellcheck.yml + - '**/*.sh' + - justfile jobs: - markdownlint: + sh-lint: timeout-minutes: 5 runs-on: ubuntu-latest - container: ghcr.io/linkerd/dev:v26-tools + container: ghcr.io/linkerd/dev:v28-tools steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - - run: just shellcheck + - run: just sh-lint diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 89a58d9ad..dd215cca7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,7 @@ jobs: meshtls: timeout-minutes: 10 runs-on: ubuntu-latest - container: ghcr.io/linkerd/dev:v26-rust + container: ghcr.io/linkerd/dev:v28-rust steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - run: just fetch @@ -42,7 +42,7 @@ jobs: unit: timeout-minutes: 10 runs-on: ubuntu-latest - container: ghcr.io/linkerd/dev:v26-rust + container: ghcr.io/linkerd/dev:v28-rust steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - run: just fetch diff --git a/.github/workflows/toolchain.yml b/.github/workflows/toolchain.yml index ea878ddaa..f23d5d40f 100644 --- a/.github/workflows/toolchain.yml +++ b/.github/workflows/toolchain.yml @@ -14,7 +14,7 @@ permissions: jobs: devcontainer: runs-on: ubuntu-latest - container: ghcr.io/linkerd/dev:v26-rust + container: ghcr.io/linkerd/dev:v28-rust steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - run: | @@ -42,7 +42,7 @@ jobs: workflows: runs-on: ubuntu-latest - container: ghcr.io/linkerd/dev:v26-tools + container: ghcr.io/linkerd/dev:v28-tools steps: - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - shell: bash diff --git a/justfile b/justfile index 8b5461d8e..c2af9f182 100644 --- a/justfile +++ b/justfile @@ -82,8 +82,8 @@ _test := if env_var_or_default("GITHUB_ACTIONS", "") == "true" { "test" } else { # Recipes # -# Run all tests and build the proxy -default: fetch check-fmt lint test build +# Run all lints +lint: sh-lint md-lint clippy doc action-lint action-dev-check # Fetch dependencies fetch: @@ -96,9 +96,6 @@ fmt: check-fmt: {{ cargo }} fmt -- --check -# Run all lints -lint: shellcheck markdownlint clippy doc actions-lint actions-dev-versions - check *flags: {{ cargo }} check --workspace --all-targets --frozen {{ flags }} {{ _fmt }} @@ -184,23 +181,17 @@ docker mode='load': {{ if features != "" { "--build-arg PROXY_FEATURES=" + features } else { "" } }} \ {{ if mode == 'push' { "--push" } else { "--load" } }} -# Display the git history minus dependabot updates -history *paths='.': - @-git log --oneline --graph --invert-grep --author="dependabot" -- {{ paths }} - # Lints all shell scripts in the repo. -shellcheck: +sh-lint: #!/usr/bin/env bash set -euo pipefail - files=$(for f in $(find . -type f ! \( -path ./.git/\* -or -path \*/target/\* \)) ; do - if [ $(file -b --mime-type $f) = text/x-shellscript ]; then - echo -n "$f " - fi - done) - echo shellcheck $files + files=$(while IFS= read -r f ; do + if [ "$(file -b --mime-type "$f")" = text/x-shellscript ]; then echo "$f"; fi + done < <(find . -type f ! \( -path ./.git/\* -or -path \*/target/\* \)) | xargs) + echo "shellcheck $files" >&2 shellcheck $files -markdownlint: +md-lint: markdownlint-cli2 '**/*.md' '!target' # Format actionlint output for Github Actions if running in CI. @@ -209,52 +200,16 @@ _actionlint-fmt := if env_var_or_default("GITHUB_ACTIONS", "") != "true" { "" } } # Lints all GitHub Actions workflows -actions-lint: +action-lint: actionlint \ {{ if _actionlint-fmt != '' { "-format '" + _actionlint-fmt + "'" } else { "" } }} \ .github/workflows/* -# Ensure all devcontainer versions are in sync -actions-dev-versions: - #!/usr/bin/env bash - set -euo pipefail - IMAGE=$(json5-to-json <.devcontainer/devcontainer.json |jq -r '.image') - check_image() { - if [ "$1" != "$IMAGE" ]; then - # Report all line numbers with the unexpected image. - for n in $(grep -nF "$1" "$2" | cut -d: -f1) ; do - if [ "${GITHUB_ACTIONS:-}" = "true" ]; then - echo "::error file=${2},line=${n}::Expected image '${IMAGE}'; found '${1}'">&2 - else - echo "${2}:${n}: Expected image '${IMAGE}'; found '${1}'" >&2 - fi - done - return 1 - fi - } - EX=0 - # Check workflows for devcontainer images - for f in .github/workflows/* ; do - # Find all container images that look like our dev image, dropping the - # `-suffix` from the tag. - for i in $(yq '.jobs.* | (.container | select(.) | (.image // .)) | match("ghcr.io/linkerd/dev:v[0-9]+").string' < "$f") ; do - if ! check_image "$i" "$f" ; then - EX=$((EX+1)) - break - fi - done - done - # Check actions for devcontainer images - while IFS= read -r f ; do - for i in $(awk 'toupper($1) ~ "FROM" { print $2 }' "$f" \ - | sed -Ene 's,(ghcr\.io/linkerd/dev:v[0-9]+).*,\1,p') - do - if ! check_image "$i" "$f" ; then - EX=$((EX+1)) - break - fi - done - done < <(find .github/actions -name Dockerfile\*) - exit $EX +action-dev-check: + action-dev-check + +# Display the git history minus dependabot updates +history *paths='.': + @-git log --oneline --graph --invert-grep --author="dependabot" -- {{ paths }} # vim: set ft=make :