mirror of https://github.com/coder/coder.git
ci: deduplicate language setup (#7753)
* Deduplicate actions * Split up go-race and go-pg
This commit is contained in:
parent
80269ba1b9
commit
555ea64669
|
@ -0,0 +1,10 @@
|
||||||
|
name: "Setup Go"
|
||||||
|
description: |
|
||||||
|
Sets up the Go environment for tests, builds, etc.
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- uses: buildjet/setup-go@v4
|
||||||
|
with:
|
||||||
|
cache: true
|
||||||
|
go-version: "~1.20"
|
|
@ -0,0 +1,15 @@
|
||||||
|
name: "Setup Node"
|
||||||
|
description: |
|
||||||
|
Sets up the node environment for tests, builds, etc.
|
||||||
|
runs:
|
||||||
|
using: "composite"
|
||||||
|
steps:
|
||||||
|
- uses: buildjet/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: 16.16.0
|
||||||
|
# See https://github.com/actions/setup-node#caching-global-packages-data
|
||||||
|
cache: "yarn"
|
||||||
|
cache-dependency-path: "site/yarn.lock"
|
||||||
|
- name: Install node_modules
|
||||||
|
shell: bash
|
||||||
|
run: ./scripts/yarn_install.sh
|
|
@ -26,9 +26,6 @@ concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
|
||||||
|
|
||||||
env:
|
|
||||||
CODER_GO_VERSION: "~1.20"
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
|
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
|
||||||
|
@ -36,11 +33,7 @@ jobs:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Install Go!
|
- uses: ./.github/actions/setup-go
|
||||||
- uses: buildjet/setup-go@v4
|
|
||||||
with:
|
|
||||||
go-version: ${{ env.CODER_GO_VERSION }}
|
|
||||||
cache: true
|
|
||||||
|
|
||||||
# Check for any typos!
|
# Check for any typos!
|
||||||
- name: Check for typos
|
- name: Check for typos
|
||||||
|
@ -67,19 +60,7 @@ jobs:
|
||||||
with:
|
with:
|
||||||
ignore: node_modules
|
ignore: node_modules
|
||||||
|
|
||||||
# Lint our dashboard!
|
- uses: ./.github/actions/setup-node
|
||||||
- name: Cache node_modules
|
|
||||||
id: cache-node
|
|
||||||
uses: buildjet/cache@v3
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
**/node_modules
|
|
||||||
.eslintcache
|
|
||||||
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
js-${{ runner.os }}-
|
|
||||||
- name: Install node_modules
|
|
||||||
run: ./scripts/yarn_install.sh
|
|
||||||
- name: Lint TypeScript
|
- name: Lint TypeScript
|
||||||
run: yarn lint
|
run: yarn lint
|
||||||
working-directory: site
|
working-directory: site
|
||||||
|
@ -139,42 +120,8 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Cache Node
|
- uses: ./.github/actions/setup-node
|
||||||
id: cache-node
|
- uses: ./.github/actions/setup-go
|
||||||
uses: buildjet/cache@v3
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
**/node_modules
|
|
||||||
.eslintcache
|
|
||||||
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
js-${{ runner.os }}-
|
|
||||||
|
|
||||||
- name: Install node_modules
|
|
||||||
run: ./scripts/yarn_install.sh
|
|
||||||
|
|
||||||
- uses: buildjet/setup-go@v4
|
|
||||||
with:
|
|
||||||
cache: false
|
|
||||||
go-version: ${{ env.CODER_GO_VERSION }}
|
|
||||||
|
|
||||||
- name: Echo Go Cache Paths
|
|
||||||
id: go-cache-paths
|
|
||||||
run: |
|
|
||||||
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_OUTPUT
|
|
||||||
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Go Build Cache
|
|
||||||
uses: buildjet/cache@v3
|
|
||||||
with:
|
|
||||||
path: ${{ steps.go-cache-paths.outputs.GOCACHE }}
|
|
||||||
key: ${{ github.job }}-go-build-${{ hashFiles('**/go.sum', '**/**.go') }}
|
|
||||||
|
|
||||||
- name: Go Mod Cache
|
|
||||||
uses: buildjet/cache@v3
|
|
||||||
with:
|
|
||||||
path: ${{ steps.go-cache-paths.outputs.GOMODCACHE }}
|
|
||||||
key: ${{ github.job }}-go-mod-${{ hashFiles('**/go.sum') }}
|
|
||||||
|
|
||||||
- name: Install sqlc
|
- name: Install sqlc
|
||||||
run: |
|
run: |
|
||||||
|
@ -219,19 +166,8 @@ jobs:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
submodules: true
|
submodules: true
|
||||||
|
|
||||||
- name: Cache Node
|
- uses: ./.github/actions/setup-node
|
||||||
id: cache-node
|
- uses: ./.github/actions/setup-go
|
||||||
uses: buildjet/cache@v3
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
**/node_modules
|
|
||||||
.eslintcache
|
|
||||||
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
js-${{ runner.os }}-
|
|
||||||
|
|
||||||
- name: Install node_modules
|
|
||||||
run: ./scripts/yarn_install.sh
|
|
||||||
|
|
||||||
- name: Install shfmt
|
- name: Install shfmt
|
||||||
run: go install mvdan.cc/sh/v3/cmd/shfmt@v3.5.0
|
run: go install mvdan.cc/sh/v3/cmd/shfmt@v3.5.0
|
||||||
|
@ -261,23 +197,7 @@ jobs:
|
||||||
cache: false
|
cache: false
|
||||||
go-version: ${{ env.CODER_GO_VERSION }}
|
go-version: ${{ env.CODER_GO_VERSION }}
|
||||||
|
|
||||||
- name: Echo Go Cache Paths
|
- uses: ./.github/actions/setup-go
|
||||||
id: go-cache-paths
|
|
||||||
run: |
|
|
||||||
echo "GOCACHE=$(go env GOCACHE)" >> ${{ runner.os == 'Windows' && '$env:' || '$' }}GITHUB_OUTPUT
|
|
||||||
echo "GOMODCACHE=$(go env GOMODCACHE)" >> ${{ runner.os == 'Windows' && '$env:' || '$' }}GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Go Build Cache
|
|
||||||
uses: buildjet/cache@v3
|
|
||||||
with:
|
|
||||||
path: ${{ steps.go-cache-paths.outputs.GOCACHE }}
|
|
||||||
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.**', '**.go') }}
|
|
||||||
|
|
||||||
- name: Go Mod Cache
|
|
||||||
uses: buildjet/cache@v3
|
|
||||||
with:
|
|
||||||
path: ${{ steps.go-cache-paths.outputs.GOMODCACHE }}
|
|
||||||
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
|
|
||||||
|
|
||||||
- name: Install gotestsum
|
- name: Install gotestsum
|
||||||
uses: jaxxstorm/action-install-gh-release@v1.10.0
|
uses: jaxxstorm/action-install-gh-release@v1.10.0
|
||||||
|
@ -335,7 +255,7 @@ jobs:
|
||||||
files: ./gotests.coverage
|
files: ./gotests.coverage
|
||||||
flags: unittest-go-${{ matrix.os }}
|
flags: unittest-go-${{ matrix.os }}
|
||||||
|
|
||||||
test-go-psql:
|
test-go-pg:
|
||||||
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
|
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
|
||||||
# This timeout must be greater than the timeout set by `go test` in
|
# This timeout must be greater than the timeout set by `go test` in
|
||||||
# `make test-postgres` to ensure we receive a trace of running
|
# `make test-postgres` to ensure we receive a trace of running
|
||||||
|
@ -345,28 +265,7 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- uses: buildjet/setup-go@v4
|
- uses: ./.github/actions/setup-go
|
||||||
with:
|
|
||||||
cache: false
|
|
||||||
go-version: ${{ env.CODER_GO_VERSION }}
|
|
||||||
|
|
||||||
- name: Echo Go Cache Paths
|
|
||||||
id: go-cache-paths
|
|
||||||
run: |
|
|
||||||
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_OUTPUT
|
|
||||||
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Go Build Cache
|
|
||||||
uses: buildjet/cache@v3
|
|
||||||
with:
|
|
||||||
path: ${{ steps.go-cache-paths.outputs.GOCACHE }}
|
|
||||||
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum', '**/**.go') }}
|
|
||||||
|
|
||||||
- name: Go Mod Cache
|
|
||||||
uses: buildjet/cache@v3
|
|
||||||
with:
|
|
||||||
path: ${{ steps.go-cache-paths.outputs.GOMODCACHE }}
|
|
||||||
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
|
|
||||||
|
|
||||||
- name: Install gotestsum
|
- name: Install gotestsum
|
||||||
uses: jaxxstorm/action-install-gh-release@v1.10.0
|
uses: jaxxstorm/action-install-gh-release@v1.10.0
|
||||||
|
@ -412,6 +311,23 @@ jobs:
|
||||||
files: ./gotests.coverage
|
files: ./gotests.coverage
|
||||||
flags: unittest-go-postgres-linux
|
flags: unittest-go-postgres-linux
|
||||||
|
|
||||||
|
test-go-race:
|
||||||
|
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
|
||||||
|
timeout-minutes: 25
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- uses: ./.github/actions/setup-go
|
||||||
|
|
||||||
|
- uses: hashicorp/setup-terraform@v2
|
||||||
|
with:
|
||||||
|
terraform_version: 1.1.9
|
||||||
|
terraform_wrapper: false
|
||||||
|
|
||||||
|
- name: Run Tests
|
||||||
|
run: |
|
||||||
|
go test -race ./...
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
name: "deploy"
|
name: "deploy"
|
||||||
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
|
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
|
||||||
|
@ -442,34 +358,8 @@ jobs:
|
||||||
cache: false
|
cache: false
|
||||||
go-version: ${{ env.CODER_GO_VERSION }}
|
go-version: ${{ env.CODER_GO_VERSION }}
|
||||||
|
|
||||||
- name: Echo Go Cache Paths
|
- uses: ./.github/actions/setup-go
|
||||||
id: go-cache-paths
|
- uses: ./.github/actions/setup-node
|
||||||
run: |
|
|
||||||
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_OUTPUT
|
|
||||||
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Go Build Cache
|
|
||||||
uses: buildjet/cache@v3
|
|
||||||
with:
|
|
||||||
path: ${{ steps.go-cache-paths.outputs.GOCACHE }}
|
|
||||||
key: ${{ runner.os }}-release-go-build-${{ hashFiles('**/go.sum') }}
|
|
||||||
|
|
||||||
- name: Go Mod Cache
|
|
||||||
uses: buildjet/cache@v3
|
|
||||||
with:
|
|
||||||
path: ${{ steps.go-cache-paths.outputs.GOMODCACHE }}
|
|
||||||
key: ${{ runner.os }}-release-go-mod-${{ hashFiles('**/go.sum') }}
|
|
||||||
|
|
||||||
- name: Cache Node
|
|
||||||
id: cache-node
|
|
||||||
uses: buildjet/cache@v3
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
**/node_modules
|
|
||||||
.eslintcache
|
|
||||||
key: js-${{ runner.os }}-release-node-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
js-${{ runner.os }}-
|
|
||||||
|
|
||||||
- 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
|
||||||
|
@ -538,23 +428,7 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Cache Node
|
- uses: ./.github/actions/setup-node
|
||||||
id: cache-node
|
|
||||||
uses: buildjet/cache@v3
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
**/node_modules
|
|
||||||
.eslintcache
|
|
||||||
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
restore-keys: |
|
|
||||||
js-${{ runner.os }}-
|
|
||||||
|
|
||||||
- uses: buildjet/setup-node@v3
|
|
||||||
with:
|
|
||||||
node-version: "16.16.0"
|
|
||||||
|
|
||||||
- name: Install node_modules
|
|
||||||
run: ./scripts/yarn_install.sh
|
|
||||||
|
|
||||||
- run: yarn test:ci --max-workers ${{ steps.cpu-cores.outputs.count }}
|
- run: yarn test:ci --max-workers ${{ steps.cpu-cores.outputs.count }}
|
||||||
working-directory: site
|
working-directory: site
|
||||||
|
@ -580,19 +454,8 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Cache Node
|
- uses: ./.github/actions/setup-node
|
||||||
id: cache-node
|
- uses: ./.github/actions/setup-go
|
||||||
uses: buildjet/cache@v3
|
|
||||||
with:
|
|
||||||
path: |
|
|
||||||
**/node_modules
|
|
||||||
.eslintcache
|
|
||||||
key: js-${{ runner.os }}-e2e-${{ hashFiles('**/yarn.lock') }}
|
|
||||||
|
|
||||||
- uses: buildjet/setup-go@v4
|
|
||||||
with:
|
|
||||||
cache: false
|
|
||||||
go-version: ${{ env.CODER_GO_VERSION }}
|
|
||||||
|
|
||||||
- uses: hashicorp/setup-terraform@v2
|
- uses: hashicorp/setup-terraform@v2
|
||||||
with:
|
with:
|
||||||
|
@ -603,24 +466,6 @@ jobs:
|
||||||
with:
|
with:
|
||||||
node-version: "16.16.0"
|
node-version: "16.16.0"
|
||||||
|
|
||||||
- name: Echo Go Cache Paths
|
|
||||||
id: go-cache-paths
|
|
||||||
run: |
|
|
||||||
echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_OUTPUT
|
|
||||||
echo "GOMODCACHE=$(go env GOMODCACHE)" >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: Go Build Cache
|
|
||||||
uses: buildjet/cache@v3
|
|
||||||
with:
|
|
||||||
path: ${{ steps.go-cache-paths.outputs.GOCACHE }}
|
|
||||||
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
|
|
||||||
|
|
||||||
- name: Go Mod Cache
|
|
||||||
uses: buildjet/cache@v3
|
|
||||||
with:
|
|
||||||
path: ${{ steps.go-cache-paths.outputs.GOMODCACHE }}
|
|
||||||
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
|
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
sudo npm install -g prettier
|
sudo npm install -g prettier
|
||||||
|
@ -655,12 +500,7 @@ jobs:
|
||||||
# only get 1 commit on shallow checkout.
|
# only get 1 commit on shallow checkout.
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- uses: buildjet/setup-node@v3
|
- uses: ./.github/actions/setup-node
|
||||||
with:
|
|
||||||
node-version: "16.16.0"
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: cd site && yarn
|
|
||||||
|
|
||||||
# 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
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -615,7 +615,7 @@ test-postgres: test-clean test-postgres-docker
|
||||||
--packages="./..." -- \
|
--packages="./..." -- \
|
||||||
-covermode=atomic -coverprofile="gotests.coverage" -timeout=20m \
|
-covermode=atomic -coverprofile="gotests.coverage" -timeout=20m \
|
||||||
-coverpkg=./... \
|
-coverpkg=./... \
|
||||||
-race -failfast
|
-failfast
|
||||||
.PHONY: test-postgres
|
.PHONY: test-postgres
|
||||||
|
|
||||||
test-postgres-docker:
|
test-postgres-docker:
|
||||||
|
|
Loading…
Reference in New Issue