diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 95dd8c98..13c496bb 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -11,22 +11,32 @@ on: jobs: - test-macos: + test: strategy: matrix: - os: [macos-latest, macos-12, macos-13] + os: [macos-latest, macos-12, macos-13, ubuntu-latest] llvm: [17] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - name: Update Homebrew - if: matrix.llvm == 17 # needed as long as LLVM 17 is still fresh + # needed as long as LLVM 17 is still fresh + if: matrix.llvm == 17 && startsWith(matrix.os, 'macos') run: brew update - name: Install LLVM ${{ matrix.llvm }} and bdw-gc + if: startsWith(matrix.os, 'macos') run: | HOMEBREW_NO_AUTO_UPDATE=1 brew install llvm@${{ matrix.llvm }} bdw-gc echo `brew --prefix llvm@${{ matrix.llvm }}`/bin >> $GITHUB_PATH + - name: Install LLVM ${{ matrix.llvm }} and libgc-dev + if: startsWith(matrix.os, 'ubuntu') + run: | + echo 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-${{ matrix.llvm }} main' | sudo tee /etc/apt/sources.list.d/llvm.list + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - + sudo apt-get update + sudo apt-get install --no-install-recommends clang-${{ matrix.llvm }} llvm-${{ matrix.llvm }}-dev libgc-dev + echo /usr/lib/llvm-${{ matrix.llvm }}/bin >> $GITHUB_PATH - name: Clang information run: | @@ -43,59 +53,35 @@ jobs: run: go build -v ./... - name: Test + if: matrix.os != 'ubuntu-latest' run: go test -v ./... - + - name: Test with coverage + if: matrix.os == 'ubuntu-latest' + run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... + - name: Install run: go install ./... - name: LLGO tests run: | - export LLGOROOT=$PWD - bash _test/run.sh - - test-linux: - runs-on: ubuntu-20.04 - strategy: - matrix: - llvm: [17] - steps: - - uses: actions/checkout@v4 - - - name: Install LLVM ${{ matrix.llvm }} and libgc-dev - run: | - echo 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-${{ matrix.llvm }} main' | sudo tee /etc/apt/sources.list.d/llvm.list - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - sudo apt-get update - sudo apt-get install --no-install-recommends clang-${{ matrix.llvm }} llvm-${{ matrix.llvm }}-dev libgc-dev - echo /usr/lib/llvm-${{ matrix.llvm }}/bin >> $GITHUB_PATH - - - name: Clang information - run: | - echo $PATH - which clang - clang --version - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '1.20' - - - name: Build - run: go build -v ./... - - - name: Test - run: go test -v -coverprofile="coverage.txt" -covermode=atomic ./... - - - name: Install - run: go install ./... + echo "Test result on ${{ matrix.os }} with LLVM ${{ matrix.llvm }}" > result.txt + LLGOROOT=$PWD bash .github/workflows/test_llgo.sh - - name: LLGO tests - run: | - export LLGOROOT=$PWD - bash _test/run.sh + - name: Test _demo and _pydemo + run: | + set +e + LLGOROOT=$PWD bash .github/workflows/test_demo.sh + exit 0 - - name: Upload coverage reports to Codecov - uses: codecov/codecov-action@v4 - with: - token: ${{ secrets.CODECOV_TOKEN }} - slug: goplus/llgo + - name: PR comment with test result + uses: thollander/actions-comment-pull-request@v2 + with: + filePath: result.md + create_if_not_exists: true + comment_tag: test-result-on-${{ matrix.os }}-with-llvm-${{ matrix.llvm }} + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4 + with: + token: ${{ secrets.CODECOV_TOKEN }} + slug: goplus/llgo diff --git a/.github/workflows/test_demo.sh b/.github/workflows/test_demo.sh new file mode 100644 index 00000000..c10cd020 --- /dev/null +++ b/.github/workflows/test_demo.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +# llgo run subdirectories under _demo and _pydemo +total=0 +failed=0 +failed_cases="" +for d in ./_demo/* ./_pydemo/*; do + total=$((total+1)) + if [ -d "$d" ]; then + echo "Testing $d" + if ! llgo run -v "$d"; then + echo "FAIL" + failed=$((failed+1)) + failed_cases="$failed_cases\n$d" + else + echo "PASS" + fi + fi +done + +echo "=== Done" +echo "$((total-failed))/$total tests passed" +if [ "$failed" -ne 0 ]; then + echo -e "Failed cases:$failed_cases" + exit 1 +fi diff --git a/_test/run.sh b/_test/run.sh index 407453d8..d048155d 100644 --- a/_test/run.sh +++ b/_test/run.sh @@ -7,7 +7,6 @@ total=$(echo "$cases" | wc -l | tr -d ' ') succ=0 for idx in $(seq 1 $((total))); do case=$(echo "$cases" | sed -n "${idx}p") - case_id=$(echo "$case" | cut -d',' -f1) case_name=$(echo "$case" | cut -d',' -f2) echo "=== Test case: $case_name" set +e