ビルドと実行を分ける
yaml
name: Runner 03
on:
workflow_dispatch:
inputs:
submission:
description: 提出コード
required: true
type: string
default: 'fn main() { proconio::input!(a: i32, b: i32); println!("{}", a + b); }'
testcases:
description: テストケース
required: true
type: string
default: '["1 2", "3 4", "12345678 87654321"]'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Build Job
env:
SUBMISSION: ${{ inputs.submission }}
run: |
cargo new worker
cd worker
cargo add proconio
printenv SUBMISSION > src/main.rs
cargo build --release
- name: Upload Binary
uses: actions/upload-artifact@v5
with:
name: worker
path: worker/target/release/worker
run:
needs: build
runs-on: ubuntu-latest
strategy:
matrix:
testcase: ${{ fromJson(inputs.testcases) }}
steps:
- name: Download Binary
uses: actions/download-artifact@v6
with:
name: worker
path: .
- name: Run Job
env:
TESTCASE: ${{ matrix.testcase }}
run: |
chmod +x worker
printenv TESTCASE | ./worker > $GITHUB_STEP_SUMMARY