|
| 1 | +name: Coder No Cache |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + - cron: "*/30 * * * *" |
| 7 | + |
| 8 | +# Cancel in-progress runs for pull requests when developers push |
| 9 | +# additional changes |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 12 | + cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 13 | + |
| 14 | +jobs: |
| 15 | + changes: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + outputs: |
| 18 | + docs-only: ${{ steps.filter.outputs.docs_count == steps.filter.outputs.all_count }} |
| 19 | + sh: ${{ steps.filter.outputs.sh }} |
| 20 | + ts: ${{ steps.filter.outputs.ts }} |
| 21 | + k8s: ${{ steps.filter.outputs.k8s }} |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v3 |
| 24 | + # For pull requests it's not necessary to checkout the code |
| 25 | + - uses: dorny/paths-filter@v2 |
| 26 | + id: filter |
| 27 | + with: |
| 28 | + filters: | |
| 29 | + all: |
| 30 | + - '**' |
| 31 | + docs: |
| 32 | + - 'docs/**' |
| 33 | + # For testing: |
| 34 | + # - '.github/**' |
| 35 | + sh: |
| 36 | + - "**.sh" |
| 37 | + ts: |
| 38 | + - 'site/**' |
| 39 | + k8s: |
| 40 | + - 'helm/**' |
| 41 | + - Dockerfile |
| 42 | + - scripts/helm.sh |
| 43 | + - id: debug |
| 44 | + run: | |
| 45 | + echo "${{ toJSON(steps.filter )}}" |
| 46 | +
|
| 47 | + check-enterprise-imports: |
| 48 | + name: check/enterprise-imports |
| 49 | + timeout-minutes: 5 |
| 50 | + runs-on: ubuntu-latest |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v3 |
| 53 | + - name: Check imports of enterprise code |
| 54 | + run: ./scripts/check_enterprise_imports.sh |
| 55 | + |
| 56 | + gen: |
| 57 | + name: "style/gen" |
| 58 | + timeout-minutes: 8 |
| 59 | + runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }} |
| 60 | + needs: changes |
| 61 | + if: needs.changes.outputs.docs-only == 'false' |
| 62 | + steps: |
| 63 | + - uses: actions/checkout@v3 |
| 64 | + |
| 65 | + - name: Install node_modules |
| 66 | + run: ./scripts/yarn_install.sh |
| 67 | + |
| 68 | + - uses: actions/setup-go@v3 |
| 69 | + with: |
| 70 | + go-version: "~1.19" |
| 71 | + |
| 72 | + - name: Install sqlc |
| 73 | + run: | |
| 74 | + curl -sSL https://github.com/kyleconroy/sqlc/releases/download/v1.13.0/sqlc_1.13.0_linux_amd64.tar.gz | sudo tar -C /usr/bin -xz sqlc |
| 75 | + - name: Install protoc-gen-go |
| 76 | + run: go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26 |
| 77 | + - name: Install protoc-gen-go-drpc |
| 78 | + run: go install storj.io/drpc/cmd/protoc-gen-go-drpc@v0.0.26 |
| 79 | + - name: Install goimports |
| 80 | + run: go install golang.org/x/tools/cmd/goimports@latest |
| 81 | + |
| 82 | + - name: Install Protoc |
| 83 | + run: | |
| 84 | + # protoc must be in lockstep with our dogfood Dockerfile |
| 85 | + # or the version in the comments will differ. |
| 86 | + set -x |
| 87 | + cd dogfood |
| 88 | + DOCKER_BUILDKIT=1 docker build . --target proto -t protoc |
| 89 | + protoc_path=/usr/local/bin/protoc |
| 90 | + docker run --rm --entrypoint cat protoc /tmp/bin/protoc > $protoc_path |
| 91 | + chmod +x $protoc_path |
| 92 | + protoc --version |
| 93 | +
|
| 94 | + - name: make gen |
| 95 | + run: "make --output-sync -j -B gen" |
| 96 | + |
| 97 | + - name: Check for unstaged files |
| 98 | + run: ./scripts/check_unstaged.sh |
| 99 | + |
| 100 | + test-go: |
| 101 | + name: "test/go" |
| 102 | + runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'windows-latest-8-cores'|| matrix.os }} |
| 103 | + timeout-minutes: 20 |
| 104 | + strategy: |
| 105 | + matrix: |
| 106 | + os: |
| 107 | + - ubuntu-latest |
| 108 | + - macos-latest |
| 109 | + - windows-2022 |
| 110 | + steps: |
| 111 | + - uses: actions/checkout@v3 |
| 112 | + |
| 113 | + - uses: actions/setup-go@v3 |
| 114 | + with: |
| 115 | + go-version: "~1.19" |
| 116 | + |
| 117 | + - name: Install gotestsum |
| 118 | + uses: jaxxstorm/action-install-gh-release@v1.7.1 |
| 119 | + env: |
| 120 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 121 | + with: |
| 122 | + repo: gotestyourself/gotestsum |
| 123 | + tag: v1.8.2 |
| 124 | + |
| 125 | + - uses: hashicorp/setup-terraform@v2 |
| 126 | + with: |
| 127 | + terraform_version: 1.1.9 |
| 128 | + terraform_wrapper: false |
| 129 | + |
| 130 | + - name: Test with Mock Database |
| 131 | + id: test |
| 132 | + shell: bash |
| 133 | + run: | |
| 134 | + # Code coverage is more computationally expensive and also |
| 135 | + # prevents test caching, so we disable it on alternate operating |
| 136 | + # systems. |
| 137 | + if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then |
| 138 | + echo ::set-output name=cover::true |
| 139 | + export COVERAGE_FLAGS='-covermode=atomic -coverprofile="gotests.coverage" -coverpkg=./...' |
| 140 | + else |
| 141 | + echo ::set-output name=cover::false |
| 142 | + fi |
| 143 | + set -x |
| 144 | + gotestsum --junitfile="gotests.xml" --packages="./..." -- -parallel=8 -timeout=3m -short -failfast $COVERAGE_FLAGS |
| 145 | +
|
| 146 | + - uses: codecov/codecov-action@v3 |
| 147 | + # This action has a tendency to error out unexpectedly, it has |
| 148 | + # the `fail_ci_if_error` option that defaults to `false`, but |
| 149 | + # that is no guarantee, see: |
| 150 | + # https://github.com/codecov/codecov-action/issues/788 |
| 151 | + continue-on-error: true |
| 152 | + if: steps.test.outputs.cover && github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork |
| 153 | + with: |
| 154 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 155 | + files: ./gotests.coverage |
| 156 | + flags: unittest-go-${{ matrix.os }} |
| 157 | + |
| 158 | + test-go-postgres: |
| 159 | + name: "test/go/postgres" |
| 160 | + runs-on: ${{ github.repository_owner == 'coder' && 'ubuntu-latest-16-cores' || 'ubuntu-latest' }} |
| 161 | + # This timeout must be greater than the timeout set by `go test` in |
| 162 | + # `make test-postgres` to ensure we receive a trace of running |
| 163 | + # goroutines. Setting this to the timeout +5m should work quite well |
| 164 | + # even if some of the preceding steps are slow. |
| 165 | + timeout-minutes: 25 |
| 166 | + steps: |
| 167 | + - uses: actions/checkout@v3 |
| 168 | + |
| 169 | + - uses: actions/setup-go@v3 |
| 170 | + with: |
| 171 | + go-version: "~1.19" |
| 172 | + |
| 173 | + - name: Install gotestsum |
| 174 | + uses: jaxxstorm/action-install-gh-release@v1.7.1 |
| 175 | + env: |
| 176 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 177 | + with: |
| 178 | + repo: gotestyourself/gotestsum |
| 179 | + tag: v1.8.2 |
| 180 | + |
| 181 | + - uses: hashicorp/setup-terraform@v2 |
| 182 | + with: |
| 183 | + terraform_version: 1.1.9 |
| 184 | + terraform_wrapper: false |
| 185 | + |
| 186 | + - name: Test with PostgreSQL Database |
| 187 | + run: make test-postgres |
| 188 | + |
| 189 | + - uses: codecov/codecov-action@v3 |
| 190 | + # This action has a tendency to error out unexpectedly, it has |
| 191 | + # the `fail_ci_if_error` option that defaults to `false`, but |
| 192 | + # that is no guarantee, see: |
| 193 | + # https://github.com/codecov/codecov-action/issues/788 |
| 194 | + continue-on-error: true |
| 195 | + if: github.actor != 'dependabot[bot]' && !github.event.pull_request.head.repo.fork |
| 196 | + with: |
| 197 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 198 | + files: ./gotests.coverage |
| 199 | + flags: unittest-go-postgres-${{ matrix.os }} |
0 commit comments