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: ./scripts/yarn_install.sh - 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-fmt: name: "style/fmt" runs-on: ubuntu-latest 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: ./scripts/yarn_install.sh - name: "make fmt" run: "make --output-sync -j fmt" test-go: name: "test/go" runs-on: ${{ matrix.os }} strategy: matrix: os: - ubuntu-latest - macos-latest - windows-2022 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: ${{ matrix.os }}-go-${{ hashFiles('**/go.sum') }} restore-keys: | ${{ matrix.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 shell: bash env: GOCOUNT: ${{ runner.os == 'Windows' && 3 || 5 }} GOMAXPROCS: ${{ runner.os == 'Windows' && 1 || 2 }} run: gotestsum --junitfile="gotests.xml" --packages="./..." -- -covermode=atomic -coverprofile="gotests.coverage" -timeout=3m -count=$GOCOUNT -race -short -failfast - name: Upload DataDog Trace if: (success() || failure()) && github.actor != 'dependabot[bot]' env: DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} DD_DATABASE: fake GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }} run: go run scripts/datadog-cireport/main.go gotests.xml - 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 -failfast - name: Upload DataDog Trace if: (success() || failure()) && github.actor != 'dependabot[bot]' && runner.os == 'Linux' env: DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} DD_DATABASE: postgresql GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }} run: go run scripts/datadog-cireport/main.go 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 deploy: name: "deploy" runs-on: ubuntu-latest if: github.event_name != 'pull_request' permissions: contents: read id-token: write steps: - uses: actions/checkout@v2 - name: Authenticate to Google Cloud uses: google-github-actions/auth@v0 with: workload_identity_provider: projects/477254869654/locations/global/workloadIdentityPools/github/providers/github service_account: github-coder@coder-ci.iam.gserviceaccount.com - name: Set up Google Cloud SDK uses: google-github-actions/setup-gcloud@v0 - name: Configure Docker for Google Artifact Registry run: gcloud auth configure-docker us-docker.pkg.dev - uses: actions/setup-node@v2 with: node-version: "14" - name: Install node_modules run: ./scripts/yarn_install.sh - uses: actions/setup-go@v2 with: go-version: "^1.17" - run: make docker/image/coder - run: docker push us-docker.pkg.dev/coder-blacktriangle-dev/ci/coder:latest - name: Update coder service run: gcloud run services update coder --image us-docker.pkg.dev/coder-blacktriangle-dev/ci/coder:latest --project coder-blacktriangle-dev --tag "git-$(git rev-parse --short HEAD)" --region us-central1 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') }} # Go is required for uploading the test results to datadog - uses: actions/setup-go@v2 with: go-version: "^1.17" - uses: actions/setup-node@v2 with: node-version: "14" - name: Install node_modules run: ./scripts/yarn_install.sh - name: Build frontend run: yarn build working-directory: site - name: Build Storybook 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 - name: Upload DataDog Trace if: (success() || failure()) && github.actor != 'dependabot[bot]' env: DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} DD_DATABASE: postgresql GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }} run: go run scripts/datadog-cireport/main.go site/test_results/junit.xml