diff --git a/.github/workflows/ci_testbuild.yml b/.github/workflows/ci_testbuild.yml index b951dd53d..e132c057f 100644 --- a/.github/workflows/ci_testbuild.yml +++ b/.github/workflows/ci_testbuild.yml @@ -21,55 +21,53 @@ jobs: - uses: maxim-lobanov/setup-xcode@v1 with: xcode-version: 15.4 + - name: Checkout uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Prepare environment + - name: Prepare CI environment run: ./scripts/github-ci-pre.sh - name: Generate and lint docs run: ./scripts/github-ci-docs.sh - - name: Upload artifacts (docstrings lint annotations) - if: always() - uses: actions/upload-artifact@v4 - with: - name: annotations.json - path: build/annotations.json - name: Build for testing run: ./scripts/github-ci-testbuild.sh - - name: Upload artifacts - if: always() - uses: actions/upload-artifact@v4 - with: - name: build.log - path: artifacts/build.log - name: Run tests id: test run: ./scripts/github-ci-test.sh - # - name: Report test results - # uses: EnricoMi/publish-unit-test-result-action/macos@v2 - # if: always() - # with: - # files: ./build/reports/junit.xml - - name: Report test results uses: kishikawakatsumi/xcresulttool@v1 with: path: build/TestResults.xcresult if: always() - - name: Upload test coverage + - name: Convert test results for Codecov + if: always() + run: | + set -o pipefail && \ + xcresultparser --output-format cobertura \ + build/TestResults.xcresult > artifacts/coverage.xml + + - name: Report test coverage to Codecov + if: always() uses: codecov/codecov-action@v4 with: verbose: false token: ${{ secrets.CODECOV_TOKEN }} - files: ./build/reports/junit.xml + plugin: xcode + files: artifacts/coverage.xml + + - name: Upload artifacts (build log) if: always() + uses: actions/upload-artifact@v4 + with: + name: build.log + path: artifacts/build.log - name: Upload artifacts (test log) if: always() @@ -77,14 +75,29 @@ jobs: with: name: test.log path: artifacts/test.log + - name: Upload artifacts (test results) if: always() uses: actions/upload-artifact@v4 with: - name: test_results - path: build/reports/junit.xml + name: TestResults.xcresult + path: artifacts/TestResults.xcresult + + - name: Upload artifacts (docstrings lint annotations) + if: always() + uses: actions/upload-artifact@v4 + with: + name: docstrings-lint-annotations.json + path: artifacts/annotations.json + + - name: Upload artifacts (coverage) + if: always() + uses: actions/upload-artifact@v4 + with: + name: coverage.xml + path: artifacts/coverage.xml - - name: Send notification (Push) + - name: Send notification (Push) if: ${{ always() && github.event_name == 'push' && github.repository == 'hammerspoon/hammerspoon' }} run: | /usr/bin/curl -H "X-CI-WebHook: true" -H "Content-Type: application/json" -d '{"secret": "${{ secrets.CI_WEBHOOK_SECRET }}", "repository": "hammerspoon", "workflow": "CI (Push)", "message": "CI for ${{ github.event.compare }} (${{ github.event.head_commit.author.name }}):\n * ${{ toJSON(github.event.head_commit.message)}}\n * ${{ steps.test.outputs.test_result }}"}' "${{ secrets.CI_WEBHOOK_URL }}" diff --git a/Brewfile b/Brewfile index 4615c8e96..0d02d56ea 100644 --- a/Brewfile +++ b/Brewfile @@ -5,4 +5,4 @@ brew "gawk" brew "cocoapods" brew "gh" brew "gpg" - +brew "a7ex/homebrew-formulae/xcresultparser" diff --git a/scripts/github-ci-docs.sh b/scripts/github-ci-docs.sh index a19fe07dd..f43390917 100755 --- a/scripts/github-ci-docs.sh +++ b/scripts/github-ci-docs.sh @@ -8,3 +8,5 @@ export IS_CI=1 ./scripts/build.sh docs -l ./scripts/build.sh docs + +cp build/annotations.json artifacts/ diff --git a/scripts/github-ci-pre.sh b/scripts/github-ci-pre.sh index f9919f696..1262f4abe 100755 --- a/scripts/github-ci-pre.sh +++ b/scripts/github-ci-pre.sh @@ -5,6 +5,7 @@ set -eu set -o pipefail export IS_CI=1 +mkdir -p artifacts # Remove the pre-installed Cocoapods binary if [ -f /usr/local/bin/pod ]; then @@ -17,5 +18,3 @@ brew bundle install # Install build dependencies ./scripts/build.sh installdeps -# Install additional CI dependencies -gem install trainer diff --git a/scripts/github-ci-test.sh b/scripts/github-ci-test.sh index a0e6b4599..79c0df65b 100755 --- a/scripts/github-ci-test.sh +++ b/scripts/github-ci-test.sh @@ -11,21 +11,8 @@ mkdir -p build/reports ./scripts/build.sh test -d -s Release -mv build/test.log artifacts - -#BUILD_ROOT="$(xcodebuild -workspace Hammerspoon.xcworkspace -scheme Release -showBuildSettings | sort | uniq | grep " BUILD_ROOT =" | awk '{ print $3 }')" -#trainer --fail_build false -p "${BUILD_ROOT}/../../Logs/Test/" -o build/reports/ - -echo "Running trainer against test results:" -find build/TestResults -ls - -trainer --fail_build false -p "build/" -o build/reports/ - -echo "Produced test reports:" -ls build/reports/*.xml - -# FIXME: Can we do this a bit more gracefully? -mv -v build/reports/*.xml build/reports/junit.xml +cp build/test.log artifacts +cp -r build/TestResults.xcresult artifacts RESULT=$(grep -A1 "Test Suite 'All tests'" artifacts/test.log | tail -1 | sed -e 's/^[ ]+//') diff --git a/scripts/github-ci-testbuild.sh b/scripts/github-ci-testbuild.sh index 9553d04db..0a9439e7e 100755 --- a/scripts/github-ci-testbuild.sh +++ b/scripts/github-ci-testbuild.sh @@ -5,10 +5,9 @@ set -eu set -o pipefail export IS_CI=1 - mkdir -p artifacts ./scripts/build.sh build -s Release -d -e -x "Hammerspoon/Build Configs/Hammerspoon-Test.xcconfig" || true # Note that even though we're building with the Release scheme, the above build actually uses the Debug configuration, so the output log is Debug-build.log -mv build/Debug-build.log artifacts/build.log +cp build/Debug-build.log artifacts/build.log