Skip to content

Commit b1c3974

Browse files
committed
allow test-go-pg to fail on windows
1 parent 9b46d8f commit b1c3974

File tree

1 file changed

+64
-20
lines changed

1 file changed

+64
-20
lines changed

.github/workflows/ci.yaml

Lines changed: 64 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,10 @@ jobs:
373373
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 }}
374374
needs: changes
375375
if: needs.changes.outputs.go == 'true' || needs.changes.outputs.ci == 'true' || github.ref == 'refs/heads/main'
376+
# This timeout must be greater than the timeout set by `go test` in
377+
# `make test-postgres` to ensure we receive a trace of running
378+
# goroutines. Setting this to the timeout +5m should work quite well
379+
# even if some of the preceding steps are slow.
376380
timeout-minutes: 25
377381
strategy:
378382
fail-fast: false
@@ -428,6 +432,21 @@ jobs:
428432
DB=ci gotestsum --format standard-quiet -- -v -short -count=1 ./...
429433
fi
430434
435+
# This is used by the `required` job to determine if the test-go-pg job
436+
# failed or not on the given OS. Matrix jobs don't support `outputs`
437+
# well - the last job to run overwrites them. Instead, we write to
438+
# artifacts.
439+
- if: always()
440+
run: echo "0" > "test-go-pg_result_${{ matrix.os }}"
441+
- if: failure()
442+
run: echo "1" > "test-go-pg_result_${{ matrix.os }}"
443+
- name: Upload result artifact
444+
if: always()
445+
uses: actions/upload-artifact@v4
446+
with:
447+
name: "test-go-pg_result_${{ matrix.os }}"
448+
path: "test-go-pg_result_${{ matrix.os }}"
449+
431450
- name: Upload test stats to Datadog
432451
timeout-minutes: 1
433452
continue-on-error: true
@@ -808,28 +827,53 @@ jobs:
808827
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
809828
with:
810829
egress-policy: audit
811-
830+
- name: Download test-go-pg Artifacts
831+
uses: actions/download-artifact@v4
832+
with:
833+
path: test-go-pg_result
834+
pattern: test-go-pg_result_*
835+
merge-multiple: true
812836
- name: Ensure required checks
837+
shell: python
813838
run: |
814-
echo "Checking required checks"
815-
echo "- fmt: ${{ needs.fmt.result }}"
816-
echo "- lint: ${{ needs.lint.result }}"
817-
echo "- gen: ${{ needs.gen.result }}"
818-
echo "- test-go: ${{ needs.test-go.result }}"
819-
echo "- test-go-pg: ${{ needs.test-go-pg.result }}"
820-
echo "- test-go-race: ${{ needs.test-go-race.result }}"
821-
echo "- test-js: ${{ needs.test-js.result }}"
822-
echo "- test-e2e: ${{ needs.test-e2e.result }}"
823-
echo "- offlinedocs: ${{ needs.offlinedocs.result }}"
824-
echo
825-
826-
# We allow skipped jobs to pass, but not failed or cancelled jobs.
827-
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" || "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
828-
echo "One of the required checks has failed or has been cancelled"
829-
exit 1
830-
fi
831-
832-
echo "Required checks have passed"
839+
import json
840+
import sys
841+
import os
842+
from pathlib import Path
843+
844+
print("Checking required checks")
845+
846+
jobs = json.loads(os.environ["NEEDS"])
847+
job_names = sorted(jobs.keys())
848+
for job_name in job_names:
849+
result = jobs[job_name]["result"]
850+
print(f"- {job_name}: {result}")
851+
print()
852+
853+
failed = False
854+
for job_name in job_names:
855+
result = jobs[job_name]["result"]
856+
857+
# Skip test-go-pg failures on windows
858+
if job_name == "test-go-pg" and result == "failure":
859+
result_artifacts = list(Path("test-go-pg_result").glob("test-go-pg_result_*"))
860+
results = {f.name: int(f.read_text()) for f in result_artifacts}
861+
del results["test-go-pg_result_windows-2022"]
862+
if sum(results.values()) == 0:
863+
print("test-go-pg on windows-2022 failed, but we are temporarily skipping it until it's fixed")
864+
continue
865+
866+
if result in ["failure", "cancelled"]:
867+
failed = True
868+
break
869+
870+
if failed:
871+
print("One of the required checks has failed or has been cancelled")
872+
sys.exit(1)
873+
874+
print("Required checks have passed")
875+
env:
876+
NEEDS: ${{ toJSON(needs) }}
833877

834878
build:
835879
# This builds and publishes ghcr.io/coder/coder-preview:main for each commit

0 commit comments

Comments
 (0)