From 8726026d706343c62150009e6c1eac839ac7b350 Mon Sep 17 00:00:00 2001 From: Oliver Gould Date: Wed, 3 Aug 2022 20:08:57 -0700 Subject: [PATCH] ci: Use devcontainer; fix release workflow (#144) * Update the devcontainer version to v22 * Use devcontainers in CI for Rust and Go workflows * Update the release automation workflow to do proper tag matching (since this repo doesn't use release/* prefixes). * Remove install-protoc action Signed-off-by: Oliver Gould --- .devcontainer/devcontainer.json | 4 +-- .github/actions/install-protoc/action.yml | 32 ----------------------- .github/workflows/go.yml | 6 +---- .github/workflows/release.yml | 31 ++++++++-------------- .github/workflows/rust.yml | 22 +++------------- 5 files changed, 18 insertions(+), 77 deletions(-) delete mode 100644 .github/actions/install-protoc/action.yml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index eec56666a..e812b8026 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,13 +1,13 @@ { "name": "linkerd2-proxy-api", - "image": "ghcr.io/linkerd/dev:v15", + "image": "ghcr.io/linkerd/dev:v22", "extensions": [ "DavidAnson.vscode-markdownlint", "golang.go", + "kokakiwi.vscode-just", "NathanRidley.autotrim", "rust-lang.rust-analyzer", "samverschueren.final-newline", - "skellock.just", "tamasfe.even-better-toml", "zxh404.vscode-proto3" ], diff --git a/.github/actions/install-protoc/action.yml b/.github/actions/install-protoc/action.yml deleted file mode 100644 index ac4a554e2..000000000 --- a/.github/actions/install-protoc/action.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: install-protoc - -description: Install protoc and set the `PROTOC` environment variablec - -inputs: - version: - required: true - description: "Protoc version" - default: "v3.20.1" - -runs: - using: composite - steps: - - name: Install protoc - shell: bash - run: | - os=linux - if [ "$(uname -s)" = Darwin ]; then - os=osx - fi - arch="$(uname -m)" - version="${{ inputs.version }}" - tmp=$(mktemp -d -t protoc.XXX) - curl --fail --silent --show-error --location \ - --proto '=https' --tlsv1.3 \ - --output "$tmp/protoc.zip" \ - "https://github.com/google/protobuf/releases/download/$version/protoc-${version#v}-$os-$arch.zip" - unzip $tmp/protoc.zip bin/protoc -d /usr/local - chmod 755 /usr/local/bin/protoc - ( echo "PROTOC_NO_VENDOR=1" - echo "PROTOC=/usr/local/bin/protoc" - ) >> $GITHUB_ENV diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 742f14bc3..374e2fbdd 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -16,13 +16,9 @@ jobs: go: timeout-minutes: 5 runs-on: ubuntu-latest + container: docker://ghcr.io/linkerd/dev:v22-go steps: - - uses: extractions/setup-just@aa5d15c144db4585980a44ebfdd2cf337c4f14cb - - uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a - with: - go-version: '1.17' - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - - uses: ./.github/actions/install-protoc - run: just go-mod-check - run: just go-gen-check - run: just go-build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f29ceb713..8f50e47d1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,14 +21,12 @@ jobs: meta: timeout-minutes: 5 runs-on: ubuntu-latest - container: - image: docker://rust:1.60 steps: - id: meta shell: bash run: | - ref=${{ github.ref }} - if [[ "$ref" == refs/tags/release/* ]]; then + ref='${{ github.ref }}' + if [[ "$ref" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+ ]]; then echo ::set-output name=publish::true echo ::set-output name=version::"${ref##refs/tags/release/}" else @@ -42,13 +40,9 @@ jobs: test: timeout-minutes: 5 runs-on: ubuntu-latest - container: - image: docker://rust:1.60 + container: docker://ghcr.io/linkerd/dev:v22-rust steps: - - uses: extractions/setup-just@aa5d15c144db4585980a44ebfdd2cf337c4f14cb - - uses: olix0r/cargo-action-fmt@ed3530f0739c46ffa0dd983f8746b8c4a3d0a01c - uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748 - - uses: ./.github/actions/install-protoc - run: just rs-fetch - run: just rs-gen-check - run: just rs-test-build @@ -61,19 +55,17 @@ jobs: contents: write timeout-minutes: 5 runs-on: ubuntu-latest - container: - image: docker://rust:1.60 + container: docker://ghcr.io/linkerd/dev:v22-rust steps: - if: needs.meta.outputs.publish uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748 - if: needs.meta.outputs.publish shell: bash run: | - curl --proto '=https' --tlsv1.3 -fsSL https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -o $HOME/jq - chmod 755 $HOME/jq - version=$(cargo metadata --format-version=1 | $HOME/jq -r '.packages[] | select(.name == "linkerd2-proxy-api") | .version') - if [[ "v${version}" != "${{ needs.meta.outputs.version }}" ]]; then - echo "::error ::Crate version v${version} does not match tag ${{ needs.meta.outputs.version }}" + version=$(cargo metadata --format-version=1 | jq -r '.packages[] | select(.name == "linkerd2-proxy-api") | .version') + expected='${{ needs.meta.outputs.version }}' + if [[ "v${version}" != "$expected" ]]; then + echo "::error ::Crate version v${version} does not match tag $expected" exit 1 fi - if: needs.meta.outputs.publish @@ -87,11 +79,10 @@ jobs: needs: [meta, release] timeout-minutes: 10 runs-on: ubuntu-latest - container: - image: docker://rust:1.60.0-bullseye + container: docker://ghcr.io/linkerd/dev:v22-rust steps: - - uses: extractions/setup-just@aa5d15c144db4585980a44ebfdd2cf337c4f14cb - uses: actions/checkout@dcd71f646680f2efd8db4afa5ad64fdcba30e748 - - run: just rs-publish --dry-run + - if: '!needs.meta.outputs.publish' + run: just rs-publish --dry-run - if: needs.meta.outputs.publish run: just rs-publish --token=${{ secrets.CRATESIO_TOKEN }} diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 3a5211233..f7c5f4c84 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -22,25 +22,17 @@ jobs: gen-check: timeout-minutes: 10 runs-on: ubuntu-latest - container: - image: docker://rust:1.60 + container: docker://ghcr.io/linkerd/dev:v22-rust steps: - - uses: olix0r/cargo-action-fmt@ed3530f0739c46ffa0dd983f8746b8c4a3d0a01c - - uses: extractions/setup-just@aa5d15c144db4585980a44ebfdd2cf337c4f14cb - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - - uses: ./.github/actions/install-protoc - run: just rs-fetch - run: just rs-gen-check rust-clippy: timeout-minutes: 10 runs-on: ubuntu-latest - container: - image: docker://rust:1.60 + container: docker://ghcr.io/linkerd/dev:v22-rust steps: - - run: rustup component add clippy - - uses: olix0r/cargo-action-fmt@ed3530f0739c46ffa0dd983f8746b8c4a3d0a01c - - uses: extractions/setup-just@aa5d15c144db4585980a44ebfdd2cf337c4f14cb - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - run: just rs-fetch - run: just rs-clippy @@ -48,11 +40,8 @@ jobs: rust-docs: timeout-minutes: 10 runs-on: ubuntu-latest - container: - image: docker://rust:1.60 + container: docker://ghcr.io/linkerd/dev:v22-rust steps: - - uses: olix0r/cargo-action-fmt@ed3530f0739c46ffa0dd983f8746b8c4a3d0a01c - - uses: extractions/setup-just@aa5d15c144db4585980a44ebfdd2cf337c4f14cb - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - run: just rs-fetch - run: just rs-docs @@ -60,11 +49,8 @@ jobs: rust-test: timeout-minutes: 10 runs-on: ubuntu-latest - container: - image: docker://rust:1.60 + container: docker://ghcr.io/linkerd/dev:v22-rust steps: - - uses: olix0r/cargo-action-fmt@ed3530f0739c46ffa0dd983f8746b8c4a3d0a01c - - uses: extractions/setup-just@aa5d15c144db4585980a44ebfdd2cf337c4f14cb - uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b - run: just rs-fetch - run: just rs-test-build