diff --git a/example/c-sum/.gitea/workflows/judge.yml b/.gitea/workflows/judge.yml similarity index 72% rename from example/c-sum/.gitea/workflows/judge.yml rename to .gitea/workflows/judge.yml index c3b85a0..aa720f5 100644 --- a/example/c-sum/.gitea/workflows/judge.yml +++ b/.gitea/workflows/judge.yml @@ -20,25 +20,56 @@ on: env: SUITE_FILE: sum.jdg SOURCES_DIR: __sources__ + EXAMPLE_DIR: example/c-sum jobs: + # Build judge once for all platforms, then ship the binaries as an artifact. + # test jobs just download and run them — no Go needed on test runners. + build_judge: + name: Build judge + runs-on: Linux-Runner + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: '1.22' + + - name: Cross-compile judge + shell: bash + run: | + mkdir -p dist + CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o dist/judge-linux-amd64 ./cmd/cli + CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o dist/judge-windows-amd64.exe ./cmd/cli + ls -la dist/ + + - name: Upload judge binaries + uses: https://github.com/christopherHX/gitea-upload-artifact@v4 + with: + name: judge-bin + path: dist/ + retention-days: 1 + test: + needs: build_judge name: "${{ matrix.toolchain.system }} / ${{ matrix.toolchain.use_compiler }} / ${{ matrix.toolchain.build_type }}${{ matrix.toolchain.wrapper != 'no' && format(' ({0})', matrix.toolchain.wrapper) || '' }}" strategy: fail-fast: false matrix: toolchain: - - { system: Linux, use_compiler: gcc, build_type: Release, cflags: "-O2", wrapper: no, timeout_factor: 1.0 } - - { system: Linux, use_compiler: gcc, build_type: Debug, cflags: "-O0 -g", wrapper: no, timeout_factor: 2.5 } - - { system: Linux, use_compiler: gcc, build_type: Sanitized, cflags: "-O1 -g -fsanitize=address,undefined", wrapper: no, timeout_factor: 2.5 } - - { system: Linux, use_compiler: gcc, build_type: Debug, cflags: "-O0 -g", wrapper: valgrind, timeout_factor: 5.0 } - - { system: Linux, use_compiler: clang, build_type: Release, cflags: "-O2", wrapper: no, timeout_factor: 1.0 } - - { system: Linux, use_compiler: clang, build_type: Sanitized, cflags: "-O1 -g -fsanitize=address,undefined", wrapper: no, timeout_factor: 2.5 } - - { system: Windows, use_compiler: clang, build_type: Release, cflags: "-O2", wrapper: no, timeout_factor: 2.0 } - - { system: Windows, use_compiler: clang, build_type: Debug, cflags: "-O0 -g", wrapper: no, timeout_factor: 3.0 } - - { system: Windows, use_compiler: msvc, build_type: Release, cflags: "/O2", wrapper: no, timeout_factor: 2.0 } - - { system: Windows, use_compiler: msvc, build_type: Debug, cflags: "/Od /Zi", wrapper: no, timeout_factor: 5.0 } + - { system: Linux, use_compiler: gcc, build_type: Release, cflags: "-O2", wrapper: no } + - { system: Linux, use_compiler: gcc, build_type: Debug, cflags: "-O0 -g", wrapper: no } + - { system: Linux, use_compiler: gcc, build_type: Sanitized, cflags: "-O1 -g -fsanitize=address,undefined", wrapper: no } + - { system: Linux, use_compiler: gcc, build_type: Debug, cflags: "-O0 -g", wrapper: valgrind } + - { system: Linux, use_compiler: clang, build_type: Release, cflags: "-O2", wrapper: no } + - { system: Linux, use_compiler: clang, build_type: Sanitized, cflags: "-O1 -g -fsanitize=address,undefined", wrapper: no } + - { system: Windows, use_compiler: clang, build_type: Release, cflags: "-O2", wrapper: no } + - { system: Windows, use_compiler: clang, build_type: Debug, cflags: "-O0 -g", wrapper: no } + - { system: Windows, use_compiler: msvc, build_type: Release, cflags: "/O2", wrapper: no } + - { system: Windows, use_compiler: msvc, build_type: Debug, cflags: "/Od /Zi", wrapper: no } runs-on: ${{ matrix.toolchain.system }}-Runner timeout-minutes: 10 @@ -66,17 +97,29 @@ jobs: shell: bash run: | mkdir -p "${SOURCES_DIR}" - cp solution.c "${SOURCES_DIR}/" + cp "${EXAMPLE_DIR}/solution.c" "${SOURCES_DIR}/" - name: Set up MSVC environment if: matrix.toolchain.use_compiler == 'msvc' uses: ilammy/msvc-dev-cmd@v1 - - name: Install judge + - name: Download judge binary + uses: https://github.com/christopherHX/gitea-download-artifact@v4 + with: + name: judge-bin + path: judge-bin + + - name: Install judge on PATH shell: bash run: | - go install github.com/Mond1c/judge/cmd/cli@latest - echo "$HOME/go/bin" >> "$GITHUB_PATH" + mkdir -p bin + if [ "${{ matrix.toolchain.system }}" = "Windows" ]; then + cp judge-bin/judge-windows-amd64.exe bin/judge.exe + else + cp judge-bin/judge-linux-amd64 bin/judge + chmod +x bin/judge + fi + echo "$PWD/bin" >> "$GITHUB_PATH" - name: Install valgrind if: matrix.toolchain.wrapper == 'valgrind' @@ -88,7 +131,7 @@ jobs: env: WRAPPER: ${{ matrix.toolchain.wrapper }} run: | - cp ../${{ env.SUITE_FILE }} . + cp "../${EXAMPLE_DIR}/${SUITE_FILE}" . WRAPPER_ARG="" case "$WRAPPER" in @@ -97,11 +140,11 @@ jobs: *) WRAPPER_ARG="--wrapper=$WRAPPER" ;; esac - # For MSVC the suffixed .exe is produced; runner auto-detects it. - judge ${{ env.SUITE_FILE }} . --json $WRAPPER_ARG > "$GITHUB_WORKSPACE/${REPORT_NAME}.json" \ + # runner auto-detects .exe suffix on Windows + judge "$SUITE_FILE" . --json $WRAPPER_ARG > "$GITHUB_WORKSPACE/${REPORT_NAME}.json" \ || echo "judge exited non-zero (expected when tests fail)" - judge ${{ env.SUITE_FILE }} . $WRAPPER_ARG || true + judge "$SUITE_FILE" . $WRAPPER_ARG || true - name: Upload report if: ${{ always() }}