diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 29db244311ea8..001cbe601ac17 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -348,8 +348,50 @@ jobs: uses: ./.github/actions/setup-tf - name: Test with PostgreSQL Database + env: + 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: | - export TS_DEBUG_DISCO=true make test-postgres - name: Upload test stats to Datadog diff --git a/Makefile b/Makefile index ca54d51842c0b..a078c037a402a 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 @@ -814,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 \ @@ -822,11 +823,11 @@ 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 \ - gcr.io/coder-dev-1/postgres:13 \ + gcr.io/coder-dev-1/postgres:${POSTGRES_VERSION} \ -c shared_buffers=1GB \ -c work_mem=1GB \ -c effective_cache_size=1GB \ diff --git a/docker-compose.yaml b/docker-compose.yaml index 9b41c5f47ae61..58692aa73e1f1 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -25,7 +25,9 @@ services: database: condition: service_healthy database: - image: "postgres:14.2" + # Minimum supported version is 13. + # More versions here: https://hub.docker.com/_/postgres + image: "postgres:16" ports: - "5432:5432" environment: 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 && \ 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 ];