From 4aaa69756512635b111898088a4c27673f1169a2 Mon Sep 17 00:00:00 2001 From: Byeongkeun Ahn <7p54ks3@naver.com> Date: Wed, 4 Sep 2024 20:32:53 +0900 Subject: [PATCH] CI: test cargo build (w/o --release) --- .github/workflows/build-linux.yml | 6 +++++- .github/workflows/build-macos.yml | 6 +++++- .github/workflows/build-windows.yml | 6 +++++- scripts/build-and-judge.py | 13 ++++++++----- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index 1e5de320..f9b53bb2 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -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: | diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 816d11b2..26a7b064 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -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: | diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index 856eb972..1f780b67 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -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: | diff --git a/scripts/build-and-judge.py b/scripts/build-and-judge.py index 8e6da515..a1ab1e70 100644 --- a/scripts/build-and-judge.py +++ b/scripts/build-and-judge.py @@ -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() @@ -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 @@ -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]