Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
allow test-go-pg to fail on windows
  • Loading branch information
hugodutka committed Dec 2, 2024
commit cd9b4d1489bd6bc3be037fc256f94884c1cdd0d3
84 changes: 64 additions & 20 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down