From a38bc43aa4ef117103fbca21884a9e022ace8112 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Tue, 25 Jun 2024 19:40:59 +0100 Subject: [PATCH 01/10] chore(Makefile): use postgres 16 for tests --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ca54d51842c0b..a98c5a1ccc0ab 100644 --- a/Makefile +++ b/Makefile @@ -826,7 +826,7 @@ test-postgres-docker: --restart no \ --detach \ --memory 16GB \ - gcr.io/coder-dev-1/postgres:13 \ + gcr.io/coder-dev-1/postgres:16 \ -c shared_buffers=1GB \ -c work_mem=1GB \ -c effective_cache_size=1GB \ From 4201130ba0d5856fcc55aaf88eec6e974908a06c Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 26 Jun 2024 10:34:19 +0100 Subject: [PATCH 02/10] test-postgres matrix --- .github/workflows/ci.yaml | 9 ++++++++- Makefile | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 29db244311ea8..e7b326ca3a087 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -329,6 +329,11 @@ jobs: runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }} needs: - changes + strategy: + matrix: + POSTGRES_VERSION: + - "13" + - "16" if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main' # This timeout must be greater than the timeout set by `go test` in # `make test-postgres` to ensure we receive a trace of running @@ -348,8 +353,10 @@ jobs: uses: ./.github/actions/setup-tf - name: Test with PostgreSQL Database + env: + POSTGRES_VERSION: "${matrix.POSTGRES_VERSION}" + TS_DEBUG_DISCO: "true" run: | - export TS_DEBUG_DISCO=true make test-postgres - name: Upload test stats to Datadog diff --git a/Makefile b/Makefile index a98c5a1ccc0ab..ea9d0dc4876f5 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,7 @@ GOOS := $(shell go env GOOS) GOARCH := $(shell go env GOARCH) GOOS_BIN_EXT := $(if $(filter windows, $(GOOS)),.exe,) VERSION := $(shell ./scripts/version.sh) +POSTGRES_VERSION ?= 16 # Use the highest ZSTD compression level in CI. ifdef CI @@ -826,7 +827,7 @@ test-postgres-docker: --restart no \ --detach \ --memory 16GB \ - gcr.io/coder-dev-1/postgres:16 \ + gcr.io/coder-dev-1/postgres:${POSTGRES_VERSION} \ -c shared_buffers=1GB \ -c work_mem=1GB \ -c effective_cache_size=1GB \ From eef466f36e93ebcb024afcd4aceccba10b3be82e Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 26 Jun 2024 10:37:32 +0100 Subject: [PATCH 03/10] more curly braces --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e7b326ca3a087..88cec2d8ce13a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -354,7 +354,7 @@ jobs: - name: Test with PostgreSQL Database env: - POSTGRES_VERSION: "${matrix.POSTGRES_VERSION}" + POSTGRES_VERSION: "${{ matrix.POSTGRES_VERSION }}" TS_DEBUG_DISCO: "true" run: | make test-postgres From 3fcdef4aa111bab1393a1afac2c2005c77ffc409 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 26 Jun 2024 10:52:18 +0100 Subject: [PATCH 04/10] dokcer-compose.yaml: update postgres version --- docker-compose.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 9b41c5f47ae61..f3ae4d244222b 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -25,7 +25,10 @@ services: database: condition: service_healthy database: - image: "postgres:14.2" + # This is typically in line with "latest". + # Minimum supported version is 13. + # More versions here: https://hub.docker.com/_/postgres + image: "postgres:bookworm" ports: - "5432:5432" environment: From adb56efa7b0c557ecd0e6a3c1f8273c2191b309f Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 26 Jun 2024 10:57:05 +0100 Subject: [PATCH 05/10] makefile: name test container based on pg version --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ea9d0dc4876f5..a078c037a402a 100644 --- a/Makefile +++ b/Makefile @@ -815,7 +815,7 @@ test-migrations: test-postgres-docker # NOTE: we set --memory to the same size as a GitHub runner. test-postgres-docker: - docker rm -f test-postgres-docker || true + docker rm -f test-postgres-docker-${POSTGRES_VERSION} || true docker run \ --env POSTGRES_PASSWORD=postgres \ --env POSTGRES_USER=postgres \ @@ -823,7 +823,7 @@ test-postgres-docker: --env PGDATA=/tmp \ --tmpfs /tmp \ --publish 5432:5432 \ - --name test-postgres-docker \ + --name test-postgres-docker-${POSTGRES_VERSION} \ --restart no \ --detach \ --memory 16GB \ From 3c23423b22666127e28de0050fa823b1c0bf9ab2 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 26 Jun 2024 13:04:08 +0100 Subject: [PATCH 06/10] update postgres version --- dogfood/Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dogfood/Dockerfile b/dogfood/Dockerfile index 8bfdb4d2bdb0b..57520ddef67a7 100644 --- a/dogfood/Dockerfile +++ b/dogfood/Dockerfile @@ -146,7 +146,7 @@ RUN apt-get update --quiet && apt-get install --yes \ openssl \ packer \ pkg-config \ - postgresql-13 \ + postgresql-16 \ python3 \ python3-pip \ rsync \ @@ -209,8 +209,8 @@ RUN apt-get update && \ npm cache clean --force # Ensure PostgreSQL binaries are in the users $PATH. -RUN update-alternatives --install /usr/local/bin/initdb initdb /usr/lib/postgresql/13/bin/initdb 100 && \ - update-alternatives --install /usr/local/bin/postgres postgres /usr/lib/postgresql/13/bin/postgres 100 +RUN update-alternatives --install /usr/local/bin/initdb initdb /usr/lib/postgresql/16/bin/initdb 100 && \ + update-alternatives --install /usr/local/bin/postgres postgres /usr/lib/postgresql/16/bin/postgres 100 # Create links for injected dependencies RUN ln --symbolic /var/tmp/coder/coder-cli/coder /usr/local/bin/coder && \ From d0ac96a885cca74a258a3b4ce1bb48f38e0effff Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 26 Jun 2024 13:26:59 +0100 Subject: [PATCH 07/10] fixup! dokcer-compose.yaml: update postgres version --- docker-compose.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index f3ae4d244222b..89d79b69afa05 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -28,7 +28,7 @@ services: # This is typically in line with "latest". # Minimum supported version is 13. # More versions here: https://hub.docker.com/_/postgres - image: "postgres:bookworm" + image: "postgres:16" ports: - "5432:5432" environment: From 6c32fb38bea11e8672f8cd0002424051a12ec321 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 26 Jun 2024 13:27:47 +0100 Subject: [PATCH 08/10] update flake.nix --- flake.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index ca31783e36045..ee6fbca7bd923 100644 --- a/flake.nix +++ b/flake.nix @@ -59,7 +59,7 @@ pixman pkg-config playwright-driver.browsers - postgresql_13 + postgresql_16 protobuf protoc-gen-go ripgrep @@ -97,7 +97,7 @@ name = "coder-${osArch}"; # Updated with ./scripts/update-flake.sh`. # This should be updated whenever go.mod changes! - vendorHash = "sha256-+K95kbYNMKiYk7obN2gjNCtBvaXBWPLKm12N6cF9ImQ="; + vendorHash = "sha256-e0L6osJwG0EF0M3TefxaAjDvN4jvQHxTGEUEECNO1Vw="; proxyVendor = true; src = ./.; nativeBuildInputs = with pkgs; [ getopt openssl zstd ]; From ef8135ad3d295b40a19559970d0f7cfd91b40b9a Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 26 Jun 2024 15:00:56 +0100 Subject: [PATCH 09/10] fixup! dokcer-compose.yaml: update postgres version --- docker-compose.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index 89d79b69afa05..58692aa73e1f1 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -25,7 +25,6 @@ services: database: condition: service_healthy database: - # This is typically in line with "latest". # Minimum supported version is 13. # More versions here: https://hub.docker.com/_/postgres image: "postgres:16" From 6bc8744fe52eeb399a392262d0cf48f6de8e31e8 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Wed, 26 Jun 2024 15:30:41 +0100 Subject: [PATCH 10/10] ci: make a separate job instead of using matrix --- .github/workflows/ci.yaml | 47 ++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 88cec2d8ce13a..001cbe601ac17 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -329,11 +329,6 @@ jobs: runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }} needs: - changes - strategy: - matrix: - POSTGRES_VERSION: - - "13" - - "16" if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main' # This timeout must be greater than the timeout set by `go test` in # `make test-postgres` to ensure we receive a trace of running @@ -354,7 +349,47 @@ jobs: - name: Test with PostgreSQL Database env: - POSTGRES_VERSION: "${{ matrix.POSTGRES_VERSION }}" + POSTGRES_VERSION: "13" + TS_DEBUG_DISCO: "true" + run: | + make test-postgres + + - name: Upload test stats to Datadog + timeout-minutes: 1 + continue-on-error: true + uses: ./.github/actions/upload-datadog + if: success() || failure() + with: + api-key: ${{ secrets.DATADOG_API_KEY }} + + # NOTE: this could instead be defined as a matrix strategy, but we want to + # only block merging if tests on postgres 13 fail. Using a matrix strategy + # here makes the check in the above `required` job rather complicated. + test-go-pg-16: + runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }} + needs: + - changes + if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main' + # This timeout must be greater than the timeout set by `go test` in + # `make test-postgres` to ensure we receive a trace of running + # goroutines. Setting this to the timeout +5m should work quite well + # even if some of the preceding steps are slow. + timeout-minutes: 25 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Setup Go + uses: ./.github/actions/setup-go + + - name: Setup Terraform + uses: ./.github/actions/setup-tf + + - name: Test with PostgreSQL Database + env: + POSTGRES_VERSION: "16" TS_DEBUG_DISCO: "true" run: | make test-postgres