From 25dcc10f22d4d607a2f3a321b0be2b2fcc639b3f Mon Sep 17 00:00:00 2001 From: Frank Lin Date: Sun, 18 Jan 2026 22:27:53 -0800 Subject: [PATCH] ci: upload artifacts and cancel stale runs --- .github/workflows/bazel.yml | 12 +++++++++++ .github/workflows/check-dictionary-sorted.yml | 4 ++++ .github/workflows/cmake.yml | 13 ++++++++++++ .github/workflows/mingw.yml | 11 ++++++++++ .github/workflows/msvc.yml | 16 +++++++++++++++ .github/workflows/nodejs.yml | 12 +++++++++++ .github/workflows/python.yml | 20 ++++++++++++++++++- test.cmd | 5 ++++- 8 files changed, 91 insertions(+), 2 deletions(-) diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index f3aa450d5..a5064115b 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -6,6 +6,10 @@ on: pull_request: branches: [master] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build-and-test: runs-on: ${{ matrix.os }} @@ -22,3 +26,11 @@ jobs: python-version: "3.12" - run: bazel build //:opencc - run: bazel test --test_output=all //src/... //data/... //test/... //python/... + - name: upload artifacts + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: opencc-bazel-${{ matrix.os }} + path: | + bazel-bin/** + bazel-testlogs/** diff --git a/.github/workflows/check-dictionary-sorted.yml b/.github/workflows/check-dictionary-sorted.yml index 3bd38c8df..ece3240a4 100644 --- a/.github/workflows/check-dictionary-sorted.yml +++ b/.github/workflows/check-dictionary-sorted.yml @@ -4,6 +4,10 @@ on: pull_request: push: +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: sort-check: runs-on: ubuntu-latest diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 32a2f2b45..95fd26b8e 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -6,6 +6,10 @@ on: pull_request: branches: [master] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build-and-test: runs-on: ${{ matrix.os }} @@ -20,3 +24,12 @@ jobs: run: make test VERBOSE=1 - name: make benchmark run: make benchmark VERBOSE=1 + - name: upload artifacts + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: opencc-cmake-${{ matrix.os }} + path: | + build/rel/** + build/dbg/** + build/perf/** diff --git a/.github/workflows/mingw.yml b/.github/workflows/mingw.yml index dd996588c..6a2885df1 100644 --- a/.github/workflows/mingw.yml +++ b/.github/workflows/mingw.yml @@ -6,6 +6,10 @@ on: pull_request: branches: [master] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build: runs-on: windows-latest @@ -30,3 +34,10 @@ jobs: run: | cd build ctest + - name: upload artifacts + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: opencc-mingw + path: | + build/** diff --git a/.github/workflows/msvc.yml b/.github/workflows/msvc.yml index 9daef8d38..bbbed3a0d 100644 --- a/.github/workflows/msvc.yml +++ b/.github/workflows/msvc.yml @@ -6,6 +6,10 @@ on: pull_request: branches: [master] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build-and-test: runs-on: windows-latest @@ -24,3 +28,15 @@ jobs: run: ./build.cmd - name: test run: ./test.cmd + - name: upload artifacts + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: opencc-msvc-${{ matrix.arch }} + path: | + bin/** + lib/** + share/** + include/** + build/ctest.log + build/Testing/** diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 6d568ec06..f0a7be1ee 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -6,6 +6,10 @@ on: pull_request: branches: [master] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: build-and-test: runs-on: ${{ matrix.os }} @@ -29,3 +33,11 @@ jobs: node-version: ${{ matrix.node-version }} - run: npm ci - run: npm test + - name: upload artifacts + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: opencc-nodejs-${{ matrix.os }}-node-${{ matrix.node-version }} + path: | + node/build/** + **/npm-debug.log diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 7e32d0a08..d2d3500db 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -6,6 +6,10 @@ on: pull_request: branches: [master] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + jobs: unit-test: runs-on: ubuntu-latest @@ -33,7 +37,14 @@ jobs: - name: Build and install run: python -m pip install . - name: Test with pytest - run: pytest python/ + run: pytest python/ --junitxml=pytest.xml + - name: upload artifacts + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: opencc-python-${{ matrix.python-version }} + path: | + pytest.xml test-pypi: strategy: @@ -67,3 +78,10 @@ jobs: env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + - name: upload artifacts + if: ${{ always() }} + uses: actions/upload-artifact@v4 + with: + name: opencc-pypi-${{ matrix.os }} + path: | + dist/** diff --git a/test.cmd b/test.cmd index 62b82e1b3..0cf0788fe 100644 --- a/test.cmd +++ b/test.cmd @@ -1,4 +1,7 @@ cmake -S. -Bbuild -DCMAKE_INSTALL_PREFIX:PATH=. -DENABLE_GTEST:BOOL=ON -DCMAKE_BUILD_TYPE=Debug cmake --build build --config Debug --target install cd build -ctest --verbose -C Debug +ctest --verbose -C Debug > ctest.log 2>&1 +set TEST_ERROR=%ERRORLEVEL% +type ctest.log +exit /b %TEST_ERROR%