chore: use names for all GitHub actions steps and use sqlc setup action (#8495)

This commit is contained in:
Muhammad Atif Ali
2023-07-13 22:46:18 +03:00
committed by GitHub
parent 132f1d0eb5
commit be1013899f
11 changed files with 144 additions and 70 deletions
+2 -1
View File
@@ -17,7 +17,8 @@ runs:
restore-keys: | restore-keys: |
gotoolchain-${{ runner.os }}- gotoolchain-${{ runner.os }}-
- uses: buildjet/setup-go@v4 - name: Setup Go
uses: buildjet/setup-go@v4
with: with:
# We do our own caching for implementation clarity. # We do our own caching for implementation clarity.
cache: false cache: false
+2 -1
View File
@@ -4,7 +4,8 @@ description: |
runs: runs:
using: "composite" using: "composite"
steps: steps:
- uses: buildjet/setup-node@v3 - name: Setup Node
uses: buildjet/setup-node@v3
with: with:
node-version: 16.20.1 node-version: 16.20.1
# See https://github.com/actions/setup-node#caching-global-packages-data # See https://github.com/actions/setup-node#caching-global-packages-data
+83 -39
View File
@@ -36,9 +36,11 @@ jobs:
k8s: ${{ steps.filter.outputs.k8s }} k8s: ${{ steps.filter.outputs.k8s }}
ci: ${{ steps.filter.outputs.ci }} ci: ${{ steps.filter.outputs.ci }}
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
uses: actions/checkout@v3
# For pull requests it's not necessary to checkout the code # For pull requests it's not necessary to checkout the code
- uses: dorny/paths-filter@v2 - name: check changed files
uses: dorny/paths-filter@v2
id: filter id: filter
with: with:
filters: | filters: |
@@ -101,9 +103,11 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- uses: ./.github/actions/setup-go - name: Setup Node
uses: ./.github/actions/setup-node
- uses: ./.github/actions/setup-node - name: Setup Go
uses: ./.github/actions/setup-go
- name: Get golangci-lint cache dir - name: Get golangci-lint cache dir
run: | run: |
@@ -149,14 +153,19 @@ jobs:
needs: changes needs: changes
if: needs.changes.outputs.docs-only == 'false' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main' if: needs.changes.outputs.docs-only == 'false' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/setup-node - name: Setup Node
- uses: ./.github/actions/setup-go uses: ./.github/actions/setup-node
- name: Install sqlc - name: Setup Go
run: | uses: ./.github/actions/setup-go
curl -sSL https://github.com/kyleconroy/sqlc/releases/download/v1.18.0/sqlc_1.18.0_linux_amd64.tar.gz | sudo tar -C /usr/bin -xz sqlc
- name: Setup sqlc
uses: sqlc-dev/setup-sqlc@v3
with:
sqlc-version: "1.18.0"
- name: go install tools - name: go install tools
run: | run: |
@@ -192,9 +201,11 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v3 uses: actions/checkout@v3
- uses: ./.github/actions/setup-node - name: Setup Node
uses: ./.github/actions/setup-node
- uses: buildjet/setup-go@v4 - name: Setup Go
uses: buildjet/setup-go@v4
with: with:
# This doesn't need caching. It's super fast anyways! # This doesn't need caching. It's super fast anyways!
cache: false cache: false
@@ -235,10 +246,14 @@ jobs:
- macos-latest - macos-latest
- windows-2019 - windows-2019
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/setup-go - name: Setup Go
- uses: ./.github/actions/setup-tf uses: ./.github/actions/setup-go
- name: Setup Terraform
uses: ./.github/actions/setup-tf
- name: Test with Mock Database - name: Test with Mock Database
id: test id: test
@@ -269,12 +284,14 @@ jobs:
# so we need to print the test stats to the log. # so we need to print the test stats to the log.
go run ./scripts/ci-report/main.go gotests.json | tee gotests_stats.json go run ./scripts/ci-report/main.go gotests.json | tee gotests_stats.json
- uses: ./.github/actions/upload-datadog - name: Upload test stats to Datadog
uses: ./.github/actions/upload-datadog
if: success() || failure() if: success() || failure()
with: with:
api-key: ${{ secrets.DATADOG_API_KEY }} api-key: ${{ secrets.DATADOG_API_KEY }}
- uses: codecov/codecov-action@v3 - name: Check code coverage
uses: codecov/codecov-action@v3
# This action has a tendency to error out unexpectedly, it has # This action has a tendency to error out unexpectedly, it has
# the `fail_ci_if_error` option that defaults to `false`, but # the `fail_ci_if_error` option that defaults to `false`, but
# that is no guarantee, see: # that is no guarantee, see:
@@ -296,10 +313,14 @@ jobs:
# even if some of the preceding steps are slow. # even if some of the preceding steps are slow.
timeout-minutes: 25 timeout-minutes: 25
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/setup-go - name: Setup Go
- uses: ./.github/actions/setup-tf uses: ./.github/actions/setup-go
- name: Setup Terraform
uses: ./.github/actions/setup-tf
- name: Test with PostgreSQL Database - name: Test with PostgreSQL Database
run: | run: |
@@ -313,12 +334,14 @@ jobs:
# so we need to print the test stats to the log. # so we need to print the test stats to the log.
go run ./scripts/ci-report/main.go gotests.json | tee gotests_stats.json go run ./scripts/ci-report/main.go gotests.json | tee gotests_stats.json
- uses: ./.github/actions/upload-datadog - name: Upload test stats to Datadog
uses: ./.github/actions/upload-datadog
if: success() || failure() if: success() || failure()
with: with:
api-key: ${{ secrets.DATADOG_API_KEY }} api-key: ${{ secrets.DATADOG_API_KEY }}
- uses: codecov/codecov-action@v3 - name: Check code coverage
uses: codecov/codecov-action@v3
# This action has a tendency to error out unexpectedly, it has # This action has a tendency to error out unexpectedly, it has
# the `fail_ci_if_error` option that defaults to `false`, but # the `fail_ci_if_error` option that defaults to `false`, but
# that is no guarantee, see: # that is no guarantee, see:
@@ -336,16 +359,21 @@ jobs:
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main' if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
timeout-minutes: 25 timeout-minutes: 25
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/setup-go - name: Setup Go
- uses: ./.github/actions/setup-tf uses: ./.github/actions/setup-go
- name: Setup Terraform
uses: ./.github/actions/setup-tf
- name: Run Tests - name: Run Tests
run: | run: |
gotestsum --junitfile="gotests.xml" -- -race ./... gotestsum --junitfile="gotests.xml" -- -race ./...
- uses: ./.github/actions/upload-datadog - name: Upload test stats to Datadog
uses: ./.github/actions/upload-datadog
if: always() if: always()
with: with:
api-key: ${{ secrets.DATADOG_API_KEY }} api-key: ${{ secrets.DATADOG_API_KEY }}
@@ -362,7 +390,8 @@ jobs:
contents: read contents: read
id-token: write id-token: write
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
@@ -375,8 +404,11 @@ jobs:
- name: Set up Google Cloud SDK - name: Set up Google Cloud SDK
uses: google-github-actions/setup-gcloud@v1 uses: google-github-actions/setup-gcloud@v1
- uses: ./.github/actions/setup-go - name: Setup Node
- uses: ./.github/actions/setup-node uses: ./.github/actions/setup-node
- name: Setup Go
uses: ./.github/actions/setup-go
- name: Install goimports - name: Install goimports
run: go install golang.org/x/tools/cmd/goimports@latest run: go install golang.org/x/tools/cmd/goimports@latest
@@ -430,7 +462,8 @@ jobs:
echo "::endgroup::" echo "::endgroup::"
done done
- uses: actions/upload-artifact@v3 - name: Upload build artifacts
uses: actions/upload-artifact@v3
with: with:
name: coder name: coder
path: | path: |
@@ -445,14 +478,17 @@ jobs:
if: needs.changes.outputs.ts == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main' if: needs.changes.outputs.ts == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
timeout-minutes: 20 timeout-minutes: 20
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/setup-node - name: Setup Node
uses: ./.github/actions/setup-node
- run: yarn test:ci --max-workers $(nproc) - run: yarn test:ci --max-workers $(nproc)
working-directory: site working-directory: site
- uses: codecov/codecov-action@v3 - name: Check code coverage
uses: codecov/codecov-action@v3
# This action has a tendency to error out unexpectedly, it has # This action has a tendency to error out unexpectedly, it has
# the `fail_ci_if_error` option that defaults to `false`, but # the `fail_ci_if_error` option that defaults to `false`, but
# that is no guarantee, see: # that is no guarantee, see:
@@ -470,11 +506,17 @@ jobs:
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ts == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main' if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ts == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
timeout-minutes: 20 timeout-minutes: 20
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/setup-node - name: Setup Node
- uses: ./.github/actions/setup-go uses: ./.github/actions/setup-node
- uses: ./.github/actions/setup-tf
- name: Setup Go
uses: ./.github/actions/setup-go
- name: Setup Terraform
uses: ./.github/actions/setup-tf
- name: Build - name: Build
run: | run: |
@@ -503,13 +545,15 @@ jobs:
needs: changes needs: changes
if: needs.changes.outputs.ts == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main' if: needs.changes.outputs.ts == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
uses: actions/checkout@v3
with: with:
# Required by Chromatic for build-over-build history, otherwise we # Required by Chromatic for build-over-build history, otherwise we
# only get 1 commit on shallow checkout. # only get 1 commit on shallow checkout.
fetch-depth: 0 fetch-depth: 0
- uses: ./.github/actions/setup-node - name: Setup Node
uses: ./.github/actions/setup-node
# This step is not meant for mainline because any detected changes to # This step is not meant for mainline because any detected changes to
# storybook snapshots will require manual approval/review in order for # storybook snapshots will require manual approval/review in order for
+4 -2
View File
@@ -25,7 +25,8 @@ jobs:
permissions: permissions:
pull-requests: write pull-requests: write
steps: steps:
- uses: hmarr/auto-approve-action@v3 - name: auto-approve dependabot
uses: hmarr/auto-approve-action@v3
if: github.actor == 'dependabot[bot]' if: github.actor == 'dependabot[bot]'
cla: cla:
@@ -52,7 +53,8 @@ jobs:
# Skip tagging for draft PRs. # Skip tagging for draft PRs.
if: ${{ github.event_name == 'pull_request_target' && success() && !github.event.pull_request.draft }} if: ${{ github.event_name == 'pull_request_target' && success() && !github.event.pull_request.draft }}
steps: steps:
- uses: actions/github-script@v6 - name: release-labels
uses: actions/github-script@v6
with: with:
# This script ensures PR title and labels are in sync: # This script ensures PR title and labels are in sync:
# #
+2 -1
View File
@@ -31,7 +31,8 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: github.repository_owner == 'coder' if: github.repository_owner == 'coder'
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
uses: actions/checkout@v3
- name: Docker login - name: Docker login
uses: docker/login-action@v2 uses: docker/login-action@v2
+16 -7
View File
@@ -16,10 +16,14 @@ jobs:
# so 0.016 * 240 = 3.84 USD per run. # so 0.016 * 240 = 3.84 USD per run.
timeout-minutes: 240 timeout-minutes: 240
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
uses: actions/checkout@v3
- uses: ./.github/actions/setup-go - name: Setup Go
- uses: ./.github/actions/setup-tf uses: ./.github/actions/setup-go
- name: Setup Terraform
uses: ./.github/actions/setup-tf
- name: Run Tests - name: Run Tests
run: | run: |
@@ -28,7 +32,8 @@ jobs:
# impact. # impact.
gotestsum --junitfile="gotests.xml" -- -timeout=240m -count=10 -race ./... gotestsum --junitfile="gotests.xml" -- -timeout=240m -count=10 -race ./...
- uses: ./.github/actions/upload-datadog - name: Upload test results to DataDog
uses: ./.github/actions/upload-datadog
if: always() if: always()
with: with:
api-key: ${{ secrets.DATADOG_API_KEY }} api-key: ${{ secrets.DATADOG_API_KEY }}
@@ -38,14 +43,18 @@ jobs:
runs-on: "buildjet-2vcpu-ubuntu-2204" runs-on: "buildjet-2vcpu-ubuntu-2204"
timeout-minutes: 10 timeout-minutes: 10
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
uses: actions/checkout@v3
- name: Setup Go
uses: ./.github/actions/setup-go
- uses: ./.github/actions/setup-go
- name: Run Tests - name: Run Tests
run: | run: |
gotestsum --junitfile="gotests.xml" -- --tags="timing" -p=1 -run='_Timing/' ./... gotestsum --junitfile="gotests.xml" -- --tags="timing" -p=1 -run='_Timing/' ./...
- uses: ./.github/actions/upload-datadog - name: Upload test results to DataDog
uses: ./.github/actions/upload-datadog
if: always() if: always()
with: with:
api-key: ${{ secrets.DATADOG_API_KEY }} api-key: ${{ secrets.DATADOG_API_KEY }}
+2 -1
View File
@@ -13,4 +13,5 @@ jobs:
assign-author: assign-author:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: toshimaru/auto-author-assign@v1.6.2 - name: Assign author
uses: toshimaru/auto-author-assign@v1.6.2
+12 -7
View File
@@ -102,17 +102,21 @@ jobs:
CODER_IMAGE_TAG: ${{ needs.pr_commented.outputs.coder_image_tag }} CODER_IMAGE_TAG: ${{ needs.pr_commented.outputs.coder_image_tag }}
PR_NUMBER: ${{ needs.pr_commented.outputs.pr_number }} PR_NUMBER: ${{ needs.pr_commented.outputs.pr_number }}
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: ./.github/actions/setup-go - name: Setup Node
uses: ./.github/actions/setup-node
- uses: ./.github/actions/setup-node - name: Setup Go
uses: ./.github/actions/setup-go
- name: Install sqlc - name: Setup sqlc
run: | uses: sqlc-dev/setup-sqlc@v3
curl -sSL https://github.com/kyleconroy/sqlc/releases/download/v1.18.0/sqlc_1.18.0_linux_amd64.tar.gz | sudo tar -C /usr/bin -xz sqlc with:
sqlc-version: "1.18.0"
- name: GHCR Login - name: GHCR Login
uses: docker/login-action@v2 uses: docker/login-action@v2
@@ -147,7 +151,8 @@ jobs:
PR_TITLE: ${{ needs.pr_commented.outputs.PR_TITLE }} PR_TITLE: ${{ needs.pr_commented.outputs.PR_TITLE }}
PR_URL: ${{ needs.pr_commented.outputs.PR_URL }} PR_URL: ${{ needs.pr_commented.outputs.PR_URL }}
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
uses: actions/checkout@v3
- name: "Set up kubeconfig" - name: "Set up kubeconfig"
run: | run: |
+6 -3
View File
@@ -43,7 +43,8 @@ jobs:
outputs: outputs:
version: ${{ steps.version.outputs.version }} version: ${{ steps.version.outputs.version }}
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
@@ -94,7 +95,8 @@ jobs:
username: ${{ github.actor }} username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }} password: ${{ secrets.GITHUB_TOKEN }}
- uses: ./.github/actions/setup-go - name: Setup Go
uses: ./.github/actions/setup-go
- name: Cache Node - name: Cache Node
id: cache-node id: cache-node
@@ -335,7 +337,8 @@ jobs:
runs-on: windows-latest runs-on: windows-latest
needs: release needs: release
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
+13 -7
View File
@@ -28,14 +28,16 @@ jobs:
codeql: codeql:
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
uses: actions/checkout@v3
- name: Initialize CodeQL - name: Initialize CodeQL
uses: github/codeql-action/init@v2 uses: github/codeql-action/init@v2
with: with:
languages: go, javascript languages: go, javascript
- uses: ./.github/actions/setup-go - name: Setup Go
uses: ./.github/actions/setup-go
# Workaround to prevent CodeQL from building the dashboard. # Workaround to prevent CodeQL from building the dashboard.
- name: Remove Makefile - name: Remove Makefile
@@ -59,11 +61,13 @@ jobs:
trivy: trivy:
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }} runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
uses: actions/checkout@v3
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: ./.github/actions/setup-go - name: Setup Go
uses: ./.github/actions/setup-go
- name: Cache Node - name: Cache Node
id: cache-node id: cache-node
@@ -76,9 +80,11 @@ jobs:
restore-keys: | restore-keys: |
js-${{ runner.os }}- js-${{ runner.os }}-
- name: Install sqlc - name: Setup sqlc
run: | uses: sqlc-dev/setup-sqlc@v3
curl -sSL https://github.com/kyleconroy/sqlc/releases/download/v1.18.0/sqlc_1.18.0_linux_amd64.tar.gz | sudo tar -C /usr/bin -xz sqlc with:
sqlc-version: "1.18.0"
- name: Install yq - name: Install yq
run: go run github.com/mikefarah/yq/v4@v4.30.6 run: go run github.com/mikefarah/yq/v4@v4.30.6
- name: Install mockgen - name: Install mockgen
+2 -1
View File
@@ -12,7 +12,8 @@ jobs:
pull-requests: write pull-requests: write
actions: write actions: write
steps: steps:
- uses: actions/stale@v8.0.0 - name: stale
uses: actions/stale@v8.0.0
with: with:
stale-issue-label: "stale" stale-issue-label: "stale"
stale-pr-label: "stale" stale-pr-label: "stale"