From 56867715ba3b046b0b4b13a3f781c8f9e057783d Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Thu, 14 Nov 2024 16:02:54 +0000 Subject: [PATCH 01/23] run pg tests on macos and windows in CI --- .github/workflows/ci.yaml | 41 +++++++++++++++++++----- scripts/embedded-pg/main.go | 63 +++++++++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+), 8 deletions(-) create mode 100644 scripts/embedded-pg/main.go diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f11203d093e0d..a28240f76cd31 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -370,15 +370,17 @@ jobs: api-key: ${{ secrets.DATADOG_API_KEY }} test-go-pg: - runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }} - needs: - - changes + runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'depot-ubuntu-22.04-4' || matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'macos-latest-xlarge' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'windows-latest-16-cores' || matrix.os }} + 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 + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-2022 steps: - name: Harden Runner uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 @@ -400,8 +402,31 @@ jobs: env: POSTGRES_VERSION: "13" TS_DEBUG_DISCO: "true" + shell: bash run: | - make test-postgres + # if macOS, install google-chrome for scaletests + # As another concern, should we really have this kind of external dependency + # requirement on standard CI? + if [ "${{ matrix.os }}" == "macos-latest" ]; then + brew install google-chrome + fi + + # By default Go will use the number of logical CPUs, which + # is a fine default. + PARALLEL_FLAG="" + + # macOS will output "The default interactive shell is now zsh" + # intermittently in CI... + if [ "${{ matrix.os }}" == "macos-latest" ]; then + touch ~/.bash_profile && echo "export BASH_SILENCE_DEPRECATION_WARNING=1" >> ~/.bash_profile + fi + + if [ "${{ runner.os }}" == "Linux" ]; then + make test-postgres + else + go run scripts/embedded-pg/main.go + DB=ci gotestsum --format standard-quiet -- -v -short -count=1 ./... + fi - name: Upload test stats to Datadog timeout-minutes: 1 diff --git a/scripts/embedded-pg/main.go b/scripts/embedded-pg/main.go new file mode 100644 index 0000000000000..9009965ab02e5 --- /dev/null +++ b/scripts/embedded-pg/main.go @@ -0,0 +1,63 @@ +// Start an embedded postgres database on port 5432. Used in CI on macOS and Windows. +package main + +import ( + "database/sql" + "os" + "path/filepath" + + embeddedpostgres "github.com/fergusstrange/embedded-postgres" +) + +func main() { + postgresPath := filepath.Join(os.TempDir(), "coder-test-postgres") + ep := embeddedpostgres.NewDatabase( + embeddedpostgres.DefaultConfig(). + Version(embeddedpostgres.V16). + BinariesPath(filepath.Join(postgresPath, "bin")). + DataPath(filepath.Join(postgresPath, "data")). + RuntimePath(filepath.Join(postgresPath, "runtime")). + CachePath(filepath.Join(postgresPath, "cache")). + Username("postgres"). + Password("postgres"). + Database("postgres"). + Port(uint32(5432)). + Logger(os.Stdout), + ) + err := ep.Start() + if err != nil { + panic(err) + } + // We execute these queries instead of using the embeddedpostgres + // StartParams because it doesn't work on Windows. The library + // seems to have a bug where it sends malformed parameters to + // pg_ctl. It encloses each parameter in single quotes, which + // Windows can't handle. + paramQueries := []string{ + `ALTER SYSTEM SET effective_cache_size = '1GB';`, + `ALTER SYSTEM SET fsync = 'off';`, + `ALTER SYSTEM SET full_page_writes = 'off';`, + `ALTER SYSTEM SET max_connections = '1000';`, + `ALTER SYSTEM SET shared_buffers = '1GB';`, + `ALTER SYSTEM SET synchronous_commit = 'off';`, + } + db, err := sql.Open("postgres", "postgres://postgres:postgres@127.0.0.1:5432/postgres?sslmode=disable") + if err != nil { + panic(err) + } + for _, query := range paramQueries { + if _, err := db.Exec(query); err != nil { + panic(err) + } + } + if err := db.Close(); err != nil { + panic(err) + } + // We restart the database to apply all the parameters. + if err := ep.Stop(); err != nil { + panic(err) + } + if err := ep.Start(); err != nil { + panic(err) + } +} From fede5507c1f9393bb7f2d0a983e8265dd3438136 Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Thu, 14 Nov 2024 16:39:26 +0000 Subject: [PATCH 02/23] set default encoding on embedded pg --- scripts/embedded-pg/main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/embedded-pg/main.go b/scripts/embedded-pg/main.go index 9009965ab02e5..df307d9c7b38b 100644 --- a/scripts/embedded-pg/main.go +++ b/scripts/embedded-pg/main.go @@ -21,6 +21,7 @@ func main() { Username("postgres"). Password("postgres"). Database("postgres"). + Encoding("UTF8"). Port(uint32(5432)). Logger(os.Stdout), ) @@ -40,6 +41,7 @@ func main() { `ALTER SYSTEM SET max_connections = '1000';`, `ALTER SYSTEM SET shared_buffers = '1GB';`, `ALTER SYSTEM SET synchronous_commit = 'off';`, + `ALTER SYSTEM SET client_encoding = 'UTF8';`, } db, err := sql.Open("postgres", "postgres://postgres:postgres@127.0.0.1:5432/postgres?sslmode=disable") if err != nil { From cd9b4d1489bd6bc3be037fc256f94884c1cdd0d3 Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Fri, 15 Nov 2024 12:50:03 +0000 Subject: [PATCH 03/23] allow test-go-pg to fail on windows --- .github/workflows/ci.yaml | 84 +++++++++++++++++++++++++++++---------- 1 file changed, 64 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a28240f76cd31..e8885f5d63e26 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -373,6 +373,10 @@ jobs: runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'depot-ubuntu-22.04-4' || matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'macos-latest-xlarge' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'windows-latest-16-cores' || matrix.os }} 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 strategy: fail-fast: false @@ -428,6 +432,21 @@ jobs: DB=ci gotestsum --format standard-quiet -- -v -short -count=1 ./... fi + # This is used by the `required` job to determine if the test-go-pg job + # failed or not on the given OS. Matrix jobs don't support `outputs` + # well - the last job to run overwrites them. Instead, we write to + # artifacts. + - if: always() + run: echo "0" > "test-go-pg_result_${{ matrix.os }}" + - if: failure() + run: echo "1" > "test-go-pg_result_${{ matrix.os }}" + - name: Upload result artifact + if: always() + uses: actions/upload-artifact@v4 + with: + name: "test-go-pg_result_${{ matrix.os }}" + path: "test-go-pg_result_${{ matrix.os }}" + - name: Upload test stats to Datadog timeout-minutes: 1 continue-on-error: true @@ -808,28 +827,53 @@ jobs: uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 with: egress-policy: audit - + - name: Download test-go-pg Artifacts + uses: actions/download-artifact@v4 + with: + path: test-go-pg_result + pattern: test-go-pg_result_* + merge-multiple: true - name: Ensure required checks + shell: python run: | - echo "Checking required checks" - echo "- fmt: ${{ needs.fmt.result }}" - echo "- lint: ${{ needs.lint.result }}" - echo "- gen: ${{ needs.gen.result }}" - echo "- test-go: ${{ needs.test-go.result }}" - echo "- test-go-pg: ${{ needs.test-go-pg.result }}" - echo "- test-go-race: ${{ needs.test-go-race.result }}" - echo "- test-js: ${{ needs.test-js.result }}" - echo "- test-e2e: ${{ needs.test-e2e.result }}" - echo "- offlinedocs: ${{ needs.offlinedocs.result }}" - echo - - # We allow skipped jobs to pass, but not failed or cancelled jobs. - if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" || "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then - echo "One of the required checks has failed or has been cancelled" - exit 1 - fi - - echo "Required checks have passed" + import json + import sys + import os + from pathlib import Path + + print("Checking required checks") + + jobs = json.loads(os.environ["NEEDS"]) + job_names = sorted(jobs.keys()) + for job_name in job_names: + result = jobs[job_name]["result"] + print(f"- {job_name}: {result}") + print() + + failed = False + for job_name in job_names: + result = jobs[job_name]["result"] + + # Skip test-go-pg failures on windows + if job_name == "test-go-pg" and result == "failure": + result_artifacts = list(Path("test-go-pg_result").glob("test-go-pg_result_*")) + results = {f.name: int(f.read_text()) for f in result_artifacts} + del results["test-go-pg_result_windows-2022"] + if sum(results.values()) == 0: + print("test-go-pg on windows-2022 failed, but we are temporarily skipping it until it's fixed") + continue + + if result in ["failure", "cancelled"]: + failed = True + break + + if failed: + print("One of the required checks has failed or has been cancelled") + sys.exit(1) + + print("Required checks have passed") + env: + NEEDS: ${{ toJSON(needs) }} # Builds the dylibs and upload it as an artifact so it can be embedded in the main build build-dylib: From e7971834ebbb9bc5b0be8842b027354227c98744 Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Fri, 15 Nov 2024 12:55:38 +0000 Subject: [PATCH 04/23] add pg race test to ci --- .github/workflows/ci.yaml | 48 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e8885f5d63e26..1949dc21ac2b2 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -538,6 +538,47 @@ jobs: with: api-key: ${{ secrets.DATADOG_API_KEY }} + test-go-race-pg: + runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }} + needs: changes + if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main' + timeout-minutes: 25 + steps: + - name: Harden Runner + uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 + with: + egress-policy: audit + + - name: Checkout + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + with: + fetch-depth: 1 + + - name: Setup Go + uses: ./.github/actions/setup-go + + - name: Setup Terraform + uses: ./.github/actions/setup-tf + + # We run race tests with reduced parallelism because they use more CPU and we were finding + # instances where tests appear to hang for multiple seconds, resulting in flaky tests when + # short timeouts are used. + # c.f. discussion on https://github.com/coder/coder/pull/15106 + - name: Run Tests + env: + POSTGRES_VERSION: "16" + run: | + make test-postgres-docker + DB=ci gotestsum --junitfile="gotests.xml" -- -race -parallel 4 -p 4 ./... + + - name: Upload test stats to Datadog + timeout-minutes: 1 + continue-on-error: true + uses: ./.github/actions/upload-datadog + if: always() + with: + api-key: ${{ secrets.DATADOG_API_KEY }} + # Tailnet integration tests only run when the `tailnet` directory or `go.sum` # and `go.mod` are changed. These tests are to ensure we don't add regressions # to tailnet, either due to our code or due to updating dependencies. @@ -815,6 +856,7 @@ jobs: - test-go - test-go-pg - test-go-race + - test-go-race-pg - test-js - test-e2e - offlinedocs @@ -862,7 +904,11 @@ jobs: if sum(results.values()) == 0: print("test-go-pg on windows-2022 failed, but we are temporarily skipping it until it's fixed") continue - + + if job_name == "test-go-race-pg" and result == "failure": + print("test-go-race-pg failed, but we are temporarily skipping it until it's fixed") + continue + if result in ["failure", "cancelled"]: failed = True break From fb23890636ac031d1a47f6939f8949767559d5db Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Fri, 15 Nov 2024 13:29:56 +0000 Subject: [PATCH 05/23] require test-go-race-pg to pass --- .github/workflows/ci.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1949dc21ac2b2..728b823f5ec64 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -905,10 +905,6 @@ jobs: print("test-go-pg on windows-2022 failed, but we are temporarily skipping it until it's fixed") continue - if job_name == "test-go-race-pg" and result == "failure": - print("test-go-race-pg failed, but we are temporarily skipping it until it's fixed") - continue - if result in ["failure", "cancelled"]: failed = True break From 4e3421f3d63ea330439619c74948901999f67e6f Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Fri, 15 Nov 2024 13:47:44 +0000 Subject: [PATCH 06/23] trigger ci --- .github/workflows/ci.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 728b823f5ec64..bc017ba6da2bd 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -431,7 +431,6 @@ jobs: go run scripts/embedded-pg/main.go DB=ci gotestsum --format standard-quiet -- -v -short -count=1 ./... fi - # This is used by the `required` job to determine if the test-go-pg job # failed or not on the given OS. Matrix jobs don't support `outputs` # well - the last job to run overwrites them. Instead, we write to From 46a8c6058be6f755ed24f69228165548e31adad9 Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Fri, 15 Nov 2024 14:35:20 +0000 Subject: [PATCH 07/23] remove the fail-fast: false strategy from test-go-pg --- .github/workflows/ci.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index bc017ba6da2bd..a784bc340f47a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -379,7 +379,6 @@ jobs: # even if some of the preceding steps are slow. timeout-minutes: 25 strategy: - fail-fast: false matrix: os: - ubuntu-latest From dcfdc07cd3098927f69dc565543e600ec476c302 Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Sun, 17 Nov 2024 22:16:08 +0000 Subject: [PATCH 08/23] ensure we received results from all matrix jobs --- .github/workflows/ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a784bc340f47a..1166062e95207 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -899,7 +899,8 @@ jobs: result_artifacts = list(Path("test-go-pg_result").glob("test-go-pg_result_*")) results = {f.name: int(f.read_text()) for f in result_artifacts} del results["test-go-pg_result_windows-2022"] - if sum(results.values()) == 0: + # We should have received 3 result artifacts: linux, macos, and windows + if len(result_artifacts) == 3 and sum(results.values()) == 0: print("test-go-pg on windows-2022 failed, but we are temporarily skipping it until it's fixed") continue From 5d79aeaba32966a374f576be7766d4228a7d2466 Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Sun, 17 Nov 2024 22:40:56 +0000 Subject: [PATCH 09/23] simplify the required check --- .github/workflows/ci.yaml | 132 ++++++++++++++++++++------------------ 1 file changed, 71 insertions(+), 61 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 1166062e95207..10c631a1dce01 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -370,7 +370,7 @@ jobs: api-key: ${{ secrets.DATADOG_API_KEY }} test-go-pg: - runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'depot-ubuntu-22.04-4' || matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'macos-latest-xlarge' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'windows-latest-16-cores' || matrix.os }} + runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'depot-ubuntu-22.04-4' || matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'macos-latest-xlarge'}} 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 @@ -383,7 +383,6 @@ jobs: os: - ubuntu-latest - macos-latest - - windows-2022 steps: - name: Harden Runner uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 @@ -430,20 +429,56 @@ jobs: go run scripts/embedded-pg/main.go DB=ci gotestsum --format standard-quiet -- -v -short -count=1 ./... fi - # This is used by the `required` job to determine if the test-go-pg job - # failed or not on the given OS. Matrix jobs don't support `outputs` - # well - the last job to run overwrites them. Instead, we write to - # artifacts. - - if: always() - run: echo "0" > "test-go-pg_result_${{ matrix.os }}" - - if: failure() - run: echo "1" > "test-go-pg_result_${{ matrix.os }}" - - name: Upload result artifact - if: always() - uses: actions/upload-artifact@v4 + + - 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 + # temporarily allow windows tests to fail. Using a matrix strategy here makes + # the check in the `required` job rather complicated. + test-go-pg-windows: + runs-on: ${{ github.repository_owner == 'coder' && 'windows-latest-16-cores' }} + 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: Harden Runner + uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 with: - name: "test-go-pg_result_${{ matrix.os }}" - path: "test-go-pg_result_${{ matrix.os }}" + egress-policy: audit + + - name: Checkout + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + 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: "13" + TS_DEBUG_DISCO: "true" + shell: bash + run: | + # By default Go will use the number of logical CPUs, which + # is a fine default. + PARALLEL_FLAG="" + + go run scripts/embedded-pg/main.go + DB=ci gotestsum --format standard-quiet -- -v -short -count=1 ./... - name: Upload test stats to Datadog timeout-minutes: 1 @@ -867,54 +902,29 @@ jobs: uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 with: egress-policy: audit - - name: Download test-go-pg Artifacts - uses: actions/download-artifact@v4 - with: - path: test-go-pg_result - pattern: test-go-pg_result_* - merge-multiple: true + - name: Ensure required checks - shell: python run: | - import json - import sys - import os - from pathlib import Path - - print("Checking required checks") - - jobs = json.loads(os.environ["NEEDS"]) - job_names = sorted(jobs.keys()) - for job_name in job_names: - result = jobs[job_name]["result"] - print(f"- {job_name}: {result}") - print() - - failed = False - for job_name in job_names: - result = jobs[job_name]["result"] - - # Skip test-go-pg failures on windows - if job_name == "test-go-pg" and result == "failure": - result_artifacts = list(Path("test-go-pg_result").glob("test-go-pg_result_*")) - results = {f.name: int(f.read_text()) for f in result_artifacts} - del results["test-go-pg_result_windows-2022"] - # We should have received 3 result artifacts: linux, macos, and windows - if len(result_artifacts) == 3 and sum(results.values()) == 0: - print("test-go-pg on windows-2022 failed, but we are temporarily skipping it until it's fixed") - continue - - if result in ["failure", "cancelled"]: - failed = True - break - - if failed: - print("One of the required checks has failed or has been cancelled") - sys.exit(1) - - print("Required checks have passed") - env: - NEEDS: ${{ toJSON(needs) }} + echo "Checking required checks" + echo "- fmt: ${{ needs.fmt.result }}" + echo "- lint: ${{ needs.lint.result }}" + echo "- gen: ${{ needs.gen.result }}" + echo "- test-go: ${{ needs.test-go.result }}" + echo "- test-go-pg: ${{ needs.test-go-pg.result }}" + echo "- test-go-race: ${{ needs.test-go-race.result }}" + echo "- test-go-race-pg: ${{ needs.test-go-race-pg.result }}" + echo "- test-js: ${{ needs.test-js.result }}" + echo "- test-e2e: ${{ needs.test-e2e.result }}" + echo "- offlinedocs: ${{ needs.offlinedocs.result }}" + echo + + # We allow skipped jobs to pass, but not failed or cancelled jobs. + if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" || "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then + echo "One of the required checks has failed or has been cancelled" + exit 1 + fi + + echo "Required checks have passed" # Builds the dylibs and upload it as an artifact so it can be embedded in the main build build-dylib: From 1c99f2e5a0f46fc70f59cb3c3473f15e0e4dc9e4 Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Sun, 17 Nov 2024 22:43:18 +0000 Subject: [PATCH 10/23] runners fallback --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 10c631a1dce01..f002b89849d7d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -370,7 +370,7 @@ jobs: api-key: ${{ secrets.DATADOG_API_KEY }} test-go-pg: - runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'depot-ubuntu-22.04-4' || matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'macos-latest-xlarge'}} + runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'depot-ubuntu-22.04-4' || matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'macos-latest-xlarge' || matrix.os }} 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 @@ -442,7 +442,7 @@ jobs: # temporarily allow windows tests to fail. Using a matrix strategy here makes # the check in the `required` job rather complicated. test-go-pg-windows: - runs-on: ${{ github.repository_owner == 'coder' && 'windows-latest-16-cores' }} + runs-on: ${{ github.repository_owner == 'coder' && 'windows-latest-16-cores' || 'windows-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 From de403869c9b69612ff7c17daa55e12cf2c8b276b Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Tue, 26 Nov 2024 11:45:43 +0000 Subject: [PATCH 11/23] make the windows pg test required --- .github/workflows/ci.yaml | 53 ++------------------------------------- 1 file changed, 2 insertions(+), 51 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f002b89849d7d..7472467f8ed90 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -370,7 +370,7 @@ jobs: api-key: ${{ secrets.DATADOG_API_KEY }} test-go-pg: - runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'depot-ubuntu-22.04-4' || matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'macos-latest-xlarge' || matrix.os }} + runs-on: ${{ matrix.os == 'ubuntu-latest' && github.repository_owner == 'coder' && 'depot-ubuntu-22.04-4' || matrix.os == 'macos-latest' && github.repository_owner == 'coder' && 'macos-latest-xlarge' || matrix.os == 'windows-2022' && github.repository_owner == 'coder' && 'windows-latest-16-cores' || matrix.os }} 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 @@ -383,6 +383,7 @@ jobs: os: - ubuntu-latest - macos-latest + - windows-2022 steps: - name: Harden Runner uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 @@ -438,56 +439,6 @@ jobs: with: api-key: ${{ secrets.DATADOG_API_KEY }} - # NOTE: this could instead be defined as a matrix strategy, but we want to - # temporarily allow windows tests to fail. Using a matrix strategy here makes - # the check in the `required` job rather complicated. - test-go-pg-windows: - runs-on: ${{ github.repository_owner == 'coder' && 'windows-latest-16-cores' || 'windows-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: Harden Runner - uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1 - with: - egress-policy: audit - - - name: Checkout - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - 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: "13" - TS_DEBUG_DISCO: "true" - shell: bash - run: | - # By default Go will use the number of logical CPUs, which - # is a fine default. - PARALLEL_FLAG="" - - go run scripts/embedded-pg/main.go - DB=ci gotestsum --format standard-quiet -- -v -short -count=1 ./... - - - 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. From 988c8935a2101c42c23f6a720be3d161c956e0bc Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Mon, 2 Dec 2024 12:27:03 +0000 Subject: [PATCH 12/23] use a temporary folder on the D: drive in Windows CI for postgres --- .github/workflows/ci.yaml | 6 ++++++ scripts/embedded-pg/main.go | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7472467f8ed90..d2373fcb7fe1f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -426,6 +426,12 @@ jobs: if [ "${{ runner.os }}" == "Linux" ]; then make test-postgres + elif [ "${{ runner.os }}" == "Windows" ]; then + # Create temp dir on D: drive for Windows. The default C: drive is extremely + # slow: https://github.com/actions/runner-images/issues/8755 + mkdir -p "D:/temp/embedded-pg" + go run scripts/embedded-pg/main.go -path "D:/temp/embedded-pg" + DB=ci gotestsum --format standard-quiet -- -v -short -count=1 ./... else go run scripts/embedded-pg/main.go DB=ci gotestsum --format standard-quiet -- -v -short -count=1 ./... diff --git a/scripts/embedded-pg/main.go b/scripts/embedded-pg/main.go index df307d9c7b38b..735e2ff1333d6 100644 --- a/scripts/embedded-pg/main.go +++ b/scripts/embedded-pg/main.go @@ -3,6 +3,7 @@ package main import ( "database/sql" + "flag" "os" "path/filepath" @@ -10,7 +11,15 @@ import ( ) func main() { + var customPath string + flag.StringVar(&customPath, "path", "", "Optional custom path for postgres data directory") + flag.Parse() + postgresPath := filepath.Join(os.TempDir(), "coder-test-postgres") + if customPath != "" { + postgresPath = customPath + } + ep := embeddedpostgres.NewDatabase( embeddedpostgres.DefaultConfig(). Version(embeddedpostgres.V16). From e7463ec209b06ad88e0cd56d91fe48fc34689e87 Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Mon, 2 Dec 2024 13:01:50 +0000 Subject: [PATCH 13/23] test out imdisk (ramdisk) for windows --- .github/workflows/ci.yaml | 89 +++++++++++---------------------------- 1 file changed, 24 insertions(+), 65 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d2373fcb7fe1f..ea8b2becf3f88 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -150,76 +150,35 @@ jobs: # run: git diff --exit-code lint: - needs: changes - if: needs.changes.outputs.offlinedocs-only == 'false' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main' - runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }} + runs-on: windows-latest-16-cores steps: - - name: Harden Runner - uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 - with: - egress-policy: audit - - - name: Checkout - uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 - with: - fetch-depth: 1 - - - name: Setup Node - uses: ./.github/actions/setup-node - - - name: Setup Go - uses: ./.github/actions/setup-go - - - name: Get golangci-lint cache dir + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download and Install ImDisk + shell: powershell run: | - linter_ver=$(egrep -o 'GOLANGCI_LINT_VERSION=\S+' dogfood/contents/Dockerfile | cut -d '=' -f 2) - go install github.com/golangci/golangci-lint/cmd/golangci-lint@v$linter_ver - dir=$(golangci-lint cache status | awk '/Dir/ { print $2 }') - echo "LINT_CACHE_DIR=$dir" >> $GITHUB_ENV - - - name: golangci-lint cache - uses: actions/cache@2cdf405574d6ef1f33a1d12acccd3ae82f47b3f2 # v4.1.0 - with: - path: | - ${{ env.LINT_CACHE_DIR }} - key: golangci-lint-${{ runner.os }}-${{ hashFiles('**/*.go') }} - restore-keys: | - golangci-lint-${{ runner.os }}- - - # Check for any typos - - name: Check for typos - uses: crate-ci/typos@b74202f74b4346efdbce7801d187ec57b266bac8 # v1.27.3 - with: - config: .github/workflows/typos.toml - - - name: Fix the typos - if: ${{ failure() }} + $url = "https://sourceforge.net/projects/imdisk-toolkit/files/20190130/ImDiskTk.exe" + Invoke-WebRequest -Uri $url -OutFile "ImDiskTk.exe" + Start-Process -FilePath "ImDiskTk.exe" -ArgumentList "/fullsilent" -Wait + + - name: Create RAM Disk + shell: cmd run: | - echo "::notice:: you can automatically fix typos from your CLI: - cargo install typos-cli - typos -c .github/workflows/typos.toml -w" - - # Needed for helm chart linting - - name: Install helm - uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0 - with: - version: v3.9.2 - - - name: make lint - run: | - make --output-sync=line -j lint - - - name: Check workflow files + imdisk -a -s 512M -m R: -p "/fs:ntfs /q /y" + + - name: Test RAM Disk + shell: cmd run: | - bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) 1.7.4 - ./actionlint -color -shellcheck= -ignore "set-output" - shell: bash - - - name: Check for unstaged files + dir R: + echo "Testing write to RAM disk" > R:\test.txt + type R:\test.txt + + - name: Cleanup RAM Disk + if: always() + shell: cmd run: | - rm -f ./actionlint ./typos - ./scripts/check_unstaged.sh - shell: bash + imdisk -D -m R: gen: timeout-minutes: 8 From b41c523a6d2d83da95ec47308d0c825222e01885 Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Mon, 2 Dec 2024 13:05:47 +0000 Subject: [PATCH 14/23] try fix --- .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 ea8b2becf3f88..381fad923fa63 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -160,7 +160,7 @@ jobs: run: | $url = "https://sourceforge.net/projects/imdisk-toolkit/files/20190130/ImDiskTk.exe" Invoke-WebRequest -Uri $url -OutFile "ImDiskTk.exe" - Start-Process -FilePath "ImDiskTk.exe" -ArgumentList "/fullsilent" -Wait + Start-Process -FilePath "ImDiskTk.exe" -ArgumentList "/fullsilent" -Wait -Verb RunAs - name: Create RAM Disk shell: cmd From 8a61183a732f3ec390be2400f96c34c45eca92ef Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Mon, 2 Dec 2024 13:10:47 +0000 Subject: [PATCH 15/23] another fix --- .github/workflows/ci.yaml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 381fad923fa63..72fedc9301ec8 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -154,13 +154,19 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v4 - - - name: Download and Install ImDisk + + - name: Download ImDisk shell: powershell run: | - $url = "https://sourceforge.net/projects/imdisk-toolkit/files/20190130/ImDiskTk.exe" - Invoke-WebRequest -Uri $url -OutFile "ImDiskTk.exe" - Start-Process -FilePath "ImDiskTk.exe" -ArgumentList "/fullsilent" -Wait -Verb RunAs + $url = "https://sourceforge.net/projects/imdisk-toolkit/files/20241123/ImDiskTk-x64.zip/download" + Invoke-WebRequest -Uri $url -OutFile "ImDiskTk.zip" + Expand-Archive -Path "ImDiskTk.zip" -DestinationPath "ImDiskTk" + + - name: Install ImDisk + shell: cmd + run: | + cd ImDiskTk + install.bat /silent - name: Create RAM Disk shell: cmd From d31913847c6dfecacebeacf0f9b32ca508aa614e Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Mon, 2 Dec 2024 13:20:05 +0000 Subject: [PATCH 16/23] fix --- .github/workflows/ci.yaml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 72fedc9301ec8..535a97a56da7f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -156,16 +156,18 @@ jobs: uses: actions/checkout@v4 - name: Download ImDisk - shell: powershell + shell: bash run: | - $url = "https://sourceforge.net/projects/imdisk-toolkit/files/20241123/ImDiskTk-x64.zip/download" - Invoke-WebRequest -Uri $url -OutFile "ImDiskTk.zip" - Expand-Archive -Path "ImDiskTk.zip" -DestinationPath "ImDiskTk" + mkdir imdisk + cd imdisk + curl -L -o files.cab https://imdisk-ci-files.pages.dev/ImDiskTk20241123/files.cab + curl -L -o install.bat https://imdisk-ci-files.pages.dev/ImDiskTk20241123/install.bat + cd .. - name: Install ImDisk shell: cmd run: | - cd ImDiskTk + cd imdisk install.bat /silent - name: Create RAM Disk From c63786ff1a5121f1f64b92fe0ed0ee48742344a8 Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Mon, 2 Dec 2024 13:24:19 +0000 Subject: [PATCH 17/23] try ramdisk with postgres --- .github/workflows/ci.yaml | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 535a97a56da7f..f339cfc34823e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -368,6 +368,29 @@ jobs: - name: Setup Terraform uses: ./.github/actions/setup-tf + - name: Download ImDisk + if: runner.os == 'Windows' + shell: bash + run: | + mkdir imdisk + cd imdisk + curl -L -o files.cab https://imdisk-ci-files.pages.dev/ImDiskTk20241123/files.cab + curl -L -o install.bat https://imdisk-ci-files.pages.dev/ImDiskTk20241123/install.bat + cd .. + + - name: Install ImDisk + if: runner.os == 'Windows' + shell: cmd + run: | + cd imdisk + install.bat /silent + + - name: Create RAM Disk + if: runner.os == 'Windows' + shell: cmd + run: | + imdisk -a -s 4096M -m R: -p "/fs:ntfs /q /y" + - name: Test with PostgreSQL Database env: POSTGRES_VERSION: "13" @@ -394,10 +417,10 @@ jobs: if [ "${{ runner.os }}" == "Linux" ]; then make test-postgres elif [ "${{ runner.os }}" == "Windows" ]; then - # Create temp dir on D: drive for Windows. The default C: drive is extremely - # slow: https://github.com/actions/runner-images/issues/8755 - mkdir -p "D:/temp/embedded-pg" - go run scripts/embedded-pg/main.go -path "D:/temp/embedded-pg" + # Create temp dir on the R: ramdisk drive for Windows. The default + # C: drive is extremely slow: https://github.com/actions/runner-images/issues/8755 + mkdir -p "R:/temp/embedded-pg" + go run scripts/embedded-pg/main.go -path "R:/temp/embedded-pg" DB=ci gotestsum --format standard-quiet -- -v -short -count=1 ./... else go run scripts/embedded-pg/main.go From ed1315435937b4fbe75db728a2f953b7797977a6 Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Mon, 2 Dec 2024 14:15:15 +0000 Subject: [PATCH 18/23] create an action for setting up imdisk --- .github/actions/setup-imdisk/action.yaml | 28 ++++++++++++++++++++++++ .github/workflows/ci.yaml | 25 +++------------------ 2 files changed, 31 insertions(+), 22 deletions(-) create mode 100644 .github/actions/setup-imdisk/action.yaml diff --git a/.github/actions/setup-imdisk/action.yaml b/.github/actions/setup-imdisk/action.yaml new file mode 100644 index 0000000000000..fe6451c3dfd4f --- /dev/null +++ b/.github/actions/setup-imdisk/action.yaml @@ -0,0 +1,28 @@ +name: "Setup ImDisk" +if: runner.os == 'Windows' +description: | + Sets up the ImDisk toolkit for Windows and creates a RAM disk on drive R:. +inputs: +runs: + using: "composite" + steps: + - name: Download ImDisk + if: runner.os == 'Windows' + shell: bash + run: | + mkdir imdisk + cd imdisk + curl -L -o files.cab https://github.com/coder/imdisk-artifacts/raw/92a17839ebc0ee3e69be019f66b3e9b5d2de4482/files.cab + curl -L -o install.bat https://github.com/coder/imdisk-artifacts/raw/92a17839ebc0ee3e69be019f66b3e9b5d2de4482/install.bat + cd .. + + - name: Install ImDisk + shell: cmd + run: | + cd imdisk + install.bat /silent + + - name: Create RAM Disk + shell: cmd + run: | + imdisk -a -s 4096M -m R: -p "/fs:ntfs /q /y" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f339cfc34823e..49ddff335ef17 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -368,28 +368,9 @@ jobs: - name: Setup Terraform uses: ./.github/actions/setup-tf - - name: Download ImDisk - if: runner.os == 'Windows' - shell: bash - run: | - mkdir imdisk - cd imdisk - curl -L -o files.cab https://imdisk-ci-files.pages.dev/ImDiskTk20241123/files.cab - curl -L -o install.bat https://imdisk-ci-files.pages.dev/ImDiskTk20241123/install.bat - cd .. - - - name: Install ImDisk - if: runner.os == 'Windows' - shell: cmd - run: | - cd imdisk - install.bat /silent - - - name: Create RAM Disk - if: runner.os == 'Windows' - shell: cmd - run: | - imdisk -a -s 4096M -m R: -p "/fs:ntfs /q /y" + # Sets up the ImDisk toolkit for Windows and creates a RAM disk on drive R:. + - name: Setup ImDisk + uses: ./.github/actions/setup-imdisk - name: Test with PostgreSQL Database env: From 4b6f183b6a55b19cea010ec73e6a2521ccf2d50e Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Mon, 2 Dec 2024 14:16:59 +0000 Subject: [PATCH 19/23] revert lint job changes --- .github/workflows/ci.yaml | 94 ++++++++++++++++++++++++++------------- 1 file changed, 64 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 49ddff335ef17..4bdceee193133 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -150,43 +150,77 @@ jobs: # run: git diff --exit-code lint: - runs-on: windows-latest-16-cores + needs: changes + if: needs.changes.outputs.offlinedocs-only == 'false' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main' + runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }} steps: - - name: Checkout code - uses: actions/checkout@v4 + - name: Harden Runner + uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2 + with: + egress-policy: audit - - name: Download ImDisk - shell: bash + - name: Checkout + uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1 + with: + fetch-depth: 1 + + - name: Setup Node + uses: ./.github/actions/setup-node + + - name: Setup Go + uses: ./.github/actions/setup-go + + - name: Get golangci-lint cache dir run: | - mkdir imdisk - cd imdisk - curl -L -o files.cab https://imdisk-ci-files.pages.dev/ImDiskTk20241123/files.cab - curl -L -o install.bat https://imdisk-ci-files.pages.dev/ImDiskTk20241123/install.bat - cd .. - - - name: Install ImDisk - shell: cmd + linter_ver=$(egrep -o 'GOLANGCI_LINT_VERSION=\S+' dogfood/contents/Dockerfile | cut -d '=' -f 2) + go install github.com/golangci/golangci-lint/cmd/golangci-lint@v$linter_ver + dir=$(golangci-lint cache status | awk '/Dir/ { print $2 }') + echo "LINT_CACHE_DIR=$dir" >> $GITHUB_ENV + + - name: golangci-lint cache + uses: actions/cache@2cdf405574d6ef1f33a1d12acccd3ae82f47b3f2 # v4.1.0 + with: + path: | + ${{ env.LINT_CACHE_DIR }} + key: golangci-lint-${{ runner.os }}-${{ hashFiles('**/*.go') }} + restore-keys: | + golangci-lint-${{ runner.os }}- + + # Check for any typos + - name: Check for typos + uses: crate-ci/typos@b74202f74b4346efdbce7801d187ec57b266bac8 # v1.27.3 + with: + config: .github/workflows/typos.toml + + - name: Fix the typos + if: ${{ failure() }} run: | - cd imdisk - install.bat /silent - - - name: Create RAM Disk - shell: cmd + echo "::notice:: you can automatically fix typos from your CLI: + cargo install typos-cli + typos -c .github/workflows/typos.toml -w" + + # Needed for helm chart linting + - name: Install helm + uses: azure/setup-helm@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0 + with: + version: v3.9.2 + + - name: make lint run: | - imdisk -a -s 512M -m R: -p "/fs:ntfs /q /y" - - - name: Test RAM Disk - shell: cmd + make --output-sync=line -j lint + + - name: Check workflow files run: | - dir R: - echo "Testing write to RAM disk" > R:\test.txt - type R:\test.txt - - - name: Cleanup RAM Disk - if: always() - shell: cmd + bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash) 1.7.4 + ./actionlint -color -shellcheck= -ignore "set-output" + shell: bash + + - name: Check for unstaged files run: | - imdisk -D -m R: + rm -f ./actionlint ./typos + ./scripts/check_unstaged.sh + shell: bash + gen: timeout-minutes: 8 From 9c7e2405458f3da5eb52e587ed8ac112c84b8c0d Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Mon, 2 Dec 2024 14:18:25 +0000 Subject: [PATCH 20/23] clarity and grammar --- .github/workflows/ci.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4bdceee193133..d778cc08b415c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -404,6 +404,7 @@ jobs: # Sets up the ImDisk toolkit for Windows and creates a RAM disk on drive R:. - name: Setup ImDisk + if: runner.os == 'Windows' uses: ./.github/actions/setup-imdisk - name: Test with PostgreSQL Database @@ -432,7 +433,7 @@ jobs: if [ "${{ runner.os }}" == "Linux" ]; then make test-postgres elif [ "${{ runner.os }}" == "Windows" ]; then - # Create temp dir on the R: ramdisk drive for Windows. The default + # Create a temp dir on the R: ramdisk drive for Windows. The default # C: drive is extremely slow: https://github.com/actions/runner-images/issues/8755 mkdir -p "R:/temp/embedded-pg" go run scripts/embedded-pg/main.go -path "R:/temp/embedded-pg" From 4969a23f8f32a1a12ebdd52bc493be6a65bcc084 Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Mon, 2 Dec 2024 14:22:37 +0000 Subject: [PATCH 21/23] fmt --- .github/actions/setup-imdisk/action.yaml | 4 ++-- .github/workflows/ci.yaml | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/actions/setup-imdisk/action.yaml b/.github/actions/setup-imdisk/action.yaml index fe6451c3dfd4f..cc73cd0fe9216 100644 --- a/.github/actions/setup-imdisk/action.yaml +++ b/.github/actions/setup-imdisk/action.yaml @@ -15,13 +15,13 @@ runs: curl -L -o files.cab https://github.com/coder/imdisk-artifacts/raw/92a17839ebc0ee3e69be019f66b3e9b5d2de4482/files.cab curl -L -o install.bat https://github.com/coder/imdisk-artifacts/raw/92a17839ebc0ee3e69be019f66b3e9b5d2de4482/install.bat cd .. - + - name: Install ImDisk shell: cmd run: | cd imdisk install.bat /silent - + - name: Create RAM Disk shell: cmd run: | diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d778cc08b415c..3d8c1002a1b4a 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -221,7 +221,6 @@ jobs: ./scripts/check_unstaged.sh shell: bash - gen: timeout-minutes: 8 runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }} From 160e77cd338ff24abd272abdd1febcc901b1772a Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Mon, 2 Dec 2024 14:35:08 +0000 Subject: [PATCH 22/23] remove empty inputs --- .github/actions/setup-imdisk/action.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/actions/setup-imdisk/action.yaml b/.github/actions/setup-imdisk/action.yaml index cc73cd0fe9216..52ef7eb08fd81 100644 --- a/.github/actions/setup-imdisk/action.yaml +++ b/.github/actions/setup-imdisk/action.yaml @@ -2,7 +2,6 @@ name: "Setup ImDisk" if: runner.os == 'Windows' description: | Sets up the ImDisk toolkit for Windows and creates a RAM disk on drive R:. -inputs: runs: using: "composite" steps: From f87261faf53c136f73fb00533774067f66eb3b6e Mon Sep 17 00:00:00 2001 From: Hugo Dutka Date: Tue, 3 Dec 2024 12:11:49 +0000 Subject: [PATCH 23/23] add link to the StartParameters issue --- scripts/embedded-pg/main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/embedded-pg/main.go b/scripts/embedded-pg/main.go index 735e2ff1333d6..018ec6e68bb69 100644 --- a/scripts/embedded-pg/main.go +++ b/scripts/embedded-pg/main.go @@ -43,6 +43,8 @@ func main() { // seems to have a bug where it sends malformed parameters to // pg_ctl. It encloses each parameter in single quotes, which // Windows can't handle. + // Related issue: + // https://github.com/fergusstrange/embedded-postgres/issues/145 paramQueries := []string{ `ALTER SYSTEM SET effective_cache_size = '1GB';`, `ALTER SYSTEM SET fsync = 'off';`,