fix: 统计整数数目 #333
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
name: Node.js CI | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.2.x] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'yarn' | |
- name: Install dependencies | |
run: yarn --frozen-lockfile | |
- name: Install LLVM 16 and lcov | |
run: | | |
rm -rf build | |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key 2>/dev/null | sudo apt-key add - | |
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main' -y | |
sudo apt-get update -q | |
sudo apt-get install -y clang-16 llvm-16 lld-16 libc++-16-dev libc++abi-16-dev clang-tools-16 clang-16-doc wasi-libc llvm-16-doc binutils ninja-build | |
wget https://github.com/Kitware/CMake/releases/download/v3.24.1/cmake-3.24.1-linux-x86_64.sh | |
sudo chmod +x cmake-3.24.1-linux-x86_64.sh | |
sudo ./cmake-3.24.1-linux-x86_64.sh --prefix=/usr --skip-license | |
shell: bash | |
- name: Gtest C++ Test | |
run: yarn test | |
env: | |
CI: true | |
NODE_ENV: test | |
CC: clang-16 | |
CXX: clang++-16 | |
- name: Generate coverage | |
run: yarn coverage lcov | |
env: | |
CI: true | |
NODE_ENV: test | |
CC: clang-16 | |
CXX: clang++-16 | |
- name: Publish Test Results | |
id: test-results | |
run: node scripts/ci-test-result-parse.cjs | |
if: always() | |
- name: Set badge color | |
shell: bash | |
run: | | |
case ${{ fromJSON( steps.test-results.outputs.json ).conclusion }} in | |
success) | |
echo "BADGE_COLOR=31c653" >> $GITHUB_ENV | |
;; | |
failure) | |
echo "BADGE_COLOR=800000" >> $GITHUB_ENV | |
;; | |
neutral) | |
echo "BADGE_COLOR=696969" >> $GITHUB_ENV | |
;; | |
esac | |
- name: Create badge | |
uses: emibcn/badge-action@d6f51ff11b5c3382b3b88689ae2d6db22d9737d1 | |
with: | |
label: Tests | |
status: '${{ fromJSON( steps.test-results.outputs.json ).stats.tests }} tests, ${{ fromJSON( steps.test-results.outputs.json ).stats.runs }} runs: ${{ fromJSON( steps.test-results.outputs.json ).conclusion }}' | |
color: ${{ env.BADGE_COLOR }} | |
style: flat | |
path: badge.svg | |
- name: Upload badge to Gist | |
# Upload only for main branch | |
if: > | |
github.event_name == 'workflow_run' && github.event.workflow_run.head_branch == 'main' || | |
github.event_name != 'workflow_run' && github.ref == 'refs/heads/main' | |
uses: andymckay/append-gist-action@1fbfbbce708a39bd45846f0955ed5521f2099c6d | |
with: | |
token: ${{ secrets.GIST_TOKEN }} | |
gistURL: https://gist.githubusercontent.com/yi-ge/cfafaf2ba23090ed9f8aa8fc875c9ce5 | |
file: badge.svg | |
- name: Coveralls | |
uses: coverallsapp/[email protected] | |
env: | |
NODE_COVERALLS_DEBUG: 1 | |
with: | |
github-token: ${{ secrets.github_token }} | |
parallel: true | |
flag-name: Unit | |
finish: | |
needs: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Coveralls Finished | |
uses: coverallsapp/[email protected] | |
with: | |
github-token: ${{ secrets.github_token }} | |
parallel-finished: true |