Files
coder/.github/workflows/coder.yaml
T
Kyle Carberry 1796dc6c2f chore: Add test helpers to improve coverage (#166)
* chore: Rename ProjectHistory to ProjectVersion

Version more accurately represents version storage. This
forks from the WorkspaceHistory name, but I think it's
easier to understand Workspace history.

* Rename files

* Standardize tests a bit more

* Remove Server struct from coderdtest

* Improve test coverage for workspace history

* Fix linting errors

* Fix coderd test leak

* Fix coderd test leak

* Improve workspace history logs

* Standardize test structure for codersdk

* Fix linting errors

* Fix WebSocket compression

* Update coderd/workspaces.go

Co-authored-by: Bryan <bryan@coder.com>

* Add test for listing project parameters

* Cache npm dependencies with setup node

* Remove windows npm cache key

Co-authored-by: Bryan <bryan@coder.com>
2022-02-05 18:24:51 -06:00

248 lines
6.7 KiB
YAML

name: coder
on:
push:
branches:
- main
- "release/*"
tags:
- "*"
pull_request:
branches:
- "*"
workflow_dispatch:
permissions:
actions: none
checks: none
contents: read
deployments: none
issues: none
packages: none
pull-requests: none
repository-projects: none
security-events: none
statuses: none
# Cancel in-progress runs for pull requests when developers push
# additional changes
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
style-lint-golangci:
name: style/lint/golangci
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.43.0
style-lint-typescript:
name: "style/lint/typescript"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Cache Node
id: cache-node
uses: actions/cache@v2
with:
path: |
**/node_modules
.eslintcache
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
- name: Install node_modules
run: yarn install
working-directory: site
- name: "yarn lint"
run: yarn lint
working-directory: site
gen:
name: "style/gen"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Protoc
uses: arduino/setup-protoc@v1
with:
version: "3.6.1"
- uses: actions/setup-go@v2
with:
go-version: "^1.17"
- run: curl -sSL
https://github.com/kyleconroy/sqlc/releases/download/v1.11.0/sqlc_1.11.0_linux_amd64.tar.gz
| sudo tar -C /usr/bin -xz sqlc
- run: go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
- run: go install storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.26
- run: "make --output-sync -j gen"
- run: ./scripts/check_unstaged.sh
style:
name: "style/${{ matrix.style }}"
runs-on: ubuntu-latest
strategy:
matrix:
style:
- fmt
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
submodules: true
- name: Cache Node
id: cache-node
uses: actions/cache@v2
with:
path: |
**/node_modules
.eslintcache
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
- name: Install node_modules
run: yarn install
working-directory: site
- name: "make ${{ matrix.style }}"
run: "make --output-sync -j ${{ matrix.style }}"
test-go:
name: "test/go"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "^1.17"
- uses: actions/cache@v2
with:
# Go mod cache, Linux build cache, Mac build cache, Windows build cache
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
%LocalAppData%\go-build
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- run: go install gotest.tools/gotestsum@latest
- uses: hashicorp/setup-terraform@v1
with:
terraform_version: 1.1.2
terraform_wrapper: false
- name: Test with Mock Database
run: gotestsum --junitfile="gotests.xml" --packages="./..." --
-covermode=atomic -coverprofile="gotests.coverage"
-timeout=3m -count=5 -race -short -parallel=2
- name: Test with PostgreSQL Database
if: runner.os == 'Linux'
run: DB=true gotestsum --junitfile="gotests.xml" --packages="./..." --
-covermode=atomic -coverprofile="gotests.coverage" -timeout=3m
-count=1 -race -parallel=2
- name: Setup Node for DataDog CLI
uses: actions/setup-node@v2
if: always() && github.actor != 'dependabot[bot]'
with:
node-version: "14"
- name: Cache DataDog CLI
if: always() && github.actor != 'dependabot[bot]'
uses: actions/cache@v2
with:
path: |
~/.npm
%LocalAppData%\npm-cache
key: datadogci-
restore-keys: datadogci-
- name: Upload DataDog Trace
if: always() && github.actor != 'dependabot[bot]'
# See: https://docs.datadoghq.com/continuous_integration/setup_tests/junit_upload/#collecting-environment-configuration-metadata
env:
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_GIT_REPOSITORY_URL: ${{ github.repositoryUrl }}
DD_GIT_BRANCH: ${{ github.head_ref }}
DD_GIT_COMMIT_SHA: ${{ github.sha }}
DD_GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
DD_GIT_COMMIT_AUTHOR_NAME: ${{ github.event.head_commit.author.name }}
DD_GIT_COMMIT_AUTHOR_EMAIL: ${{ github.event.head_commit.author.email }}
DD_GIT_COMMIT_COMMITTER_NAME: ${{ github.event.head_commit.committer.name }}
DD_GIT_COMMIT_COMMITTER_EMAIL: ${{ github.event.head_commit.committer.email }}
DD_TAGS: ${{ format('os.platform:{0},os.architecture:{1}', runner.os, runner.arch) }}
run: |
npm install -g @datadog/datadog-ci
datadog-ci junit upload --service coder gotests.xml
- uses: codecov/codecov-action@v2
if: github.actor != 'dependabot[bot]'
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./gotests.coverage
flags: unittest-go-${{ matrix.os }}
fail_ci_if_error: true
test-js:
name: "test/js"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Cache Node
id: cache-node
uses: actions/cache@v2
with:
path: |
**/node_modules
.eslintcache
key: js-${{ runner.os }}-test-${{ hashFiles('**/yarn.lock') }}
- uses: actions/setup-node@v2
with:
node-version: "14"
- run: yarn install
working-directory: site
- run: yarn build
working-directory: site
- run: yarn storybook:build
working-directory: site
- run: yarn test:coverage
working-directory: site
- uses: codecov/codecov-action@v2
if: github.actor != 'dependabot[bot]'
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./site/coverage/lcov.info
flags: unittest-js
fail_ci_if_error: true