Skip to content

Commit

Permalink
Merge pull request #106 from byeongkeunahn/ci-macos
Browse files Browse the repository at this point in the history
CI: test cargo build (w/o --release)
  • Loading branch information
byeongkeunahn authored Sep 4, 2024
2 parents fb5dc62 + 4aaa697 commit 08cefac
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,14 @@ jobs:
- name: Test
if: ${{ matrix.target != 'wasm32-unknown-unknown' && matrix.target != 'x86_64-pc-windows-gnu' }}
run: cargo test --lib -- --test-threads 1
- name: Check cargo build
if: ${{ matrix.target != 'wasm32-unknown-unknown' && matrix.target != 'x86_64-pc-windows-gnu' }}
run: |
python ./scripts/ci.py ${{ runner.temp }} _ CargoDev 0 ./tests/ci.json
- name: Check cargo build --release
if: ${{ matrix.target != 'wasm32-unknown-unknown' && matrix.target != 'x86_64-pc-windows-gnu' }}
run: |
python ./scripts/ci.py ${{ runner.temp }} _ Cargo 0 ./tests/ci.json
python ./scripts/ci.py ${{ runner.temp }} _ CargoRelease 0 ./tests/ci.json
- name: Check C (x86_64)
if: ${{ matrix.target == 'x86_64-unknown-linux-gnu' }}
run: |
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,14 @@ jobs:
- name: Test
if: ${{ matrix.target != 'wasm32-unknown-unknown' }}
run: cargo test --lib -- --test-threads 1
- name: Check cargo build
if: ${{ matrix.target != 'wasm32-unknown-unknown' }}
run: |
python3 ./scripts/ci.py ${{ runner.temp }} _ CargoDev 0 ./tests/ci.json
- name: Check cargo build --release
if: ${{ matrix.target != 'wasm32-unknown-unknown' }}
run: |
python3 ./scripts/ci.py ${{ runner.temp }} _ Cargo 0 ./tests/ci.json
python3 ./scripts/ci.py ${{ runner.temp }} _ CargoRelease 0 ./tests/ci.json
- name: Check wasm32
if: ${{ matrix.target == 'wasm32-unknown-unknown' }}
run: |
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@ jobs:
- name: Test
if: ${{ matrix.target != 'wasm32-unknown-unknown' }}
run: cargo test --lib -- --test-threads 1
- name: Check cargo build
if: ${{ matrix.target != 'wasm32-unknown-unknown' }}
run: |
python .\scripts\ci.py ${{ runner.temp }} _ CargoDev 0 .\tests\ci.json
- name: Check cargo build --release
if: ${{ matrix.target != 'wasm32-unknown-unknown' }}
run: |
python .\scripts\ci.py ${{ runner.temp }} _ Cargo 0 .\tests\ci.json
python .\scripts\ci.py ${{ runner.temp }} _ CargoRelease 0 .\tests\ci.json
- name: Check C (x86_64)
if: ${{ matrix.target == 'x86_64-pc-windows-msvc' }}
run: |
Expand Down
13 changes: 8 additions & 5 deletions scripts/build-and-judge.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ def test_equal(x, y):
sol_path = sys.argv[5]
indata_path = sys.argv[6]
outdata_path = sys.argv[7]
src_ext = {"Cargo": "cargo", "C": "c", "Rust": "rs", "JavaScript": "js"}[language]
if language == "Cargo":
build_cmd = ["cargo build --release --message-format=json"]
src_ext = {"CargoDev": "cargo", "CargoRelease": "cargo", "C": "c", "Rust": "rs", "JavaScript": "js"}[language]
if language in ["CargoDev", "CargoRelease"]:
if language == "CargoRelease":
build_cmd = ["cargo build --release --message-format=json"]
else:
build_cmd = ["cargo build --message-format=json"]
if platform.system() == "Windows":
build_cmd = build_cmd[0].split()

Expand Down Expand Up @@ -75,7 +78,7 @@ def test_equal(x, y):
p = subprocess.run(build_cmd, shell=True, capture_output=True, text=True, encoding="utf8")
if p.returncode != 0:
raise Exception("Build failed. The stdout:\n{0}\n\nThe stderr:\n{1}".format(p.stdout, p.stderr))
if language == "Cargo":
if language in ["CargoDev", "CargoRelease"]:
print(p.stderr)
cargo_stdout = [json.loads(x) for x in p.stdout.split('\n') if len(x.strip()) > 0]
basm_executable_path = None
Expand Down Expand Up @@ -110,7 +113,7 @@ def test_equal(x, y):
os.system("rustc -C opt-level=3 -o {1} {0}".format(src_path, bin_path))
elif language == "JavaScript":
run_cmd = ["node", src_path]
else: # language == "Cargo"
else: # language in ["CargoDev", "CargoRelease"]
if platform.system() != "Windows":
os.system("chmod +x {0}".format(basm_executable_path))
run_cmd = [basm_executable_path]
Expand Down

0 comments on commit 08cefac

Please sign in to comment.