Skip to content

Commit

Permalink
Lots of CI refactoring, hopefully fixing codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
cmsj committed Aug 7, 2024
1 parent 1c19107 commit 7706a41
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 44 deletions.
61 changes: 37 additions & 24 deletions .github/workflows/ci_testbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,70 +21,83 @@ 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()
uses: actions/upload-artifact@v4
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 }}"
Expand Down
2 changes: 1 addition & 1 deletion Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ brew "gawk"
brew "cocoapods"
brew "gh"
brew "gpg"

brew "a7ex/homebrew-formulae/xcresultparser"
2 changes: 2 additions & 0 deletions scripts/github-ci-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ export IS_CI=1

./scripts/build.sh docs -l
./scripts/build.sh docs

cp build/annotations.json artifacts/
3 changes: 1 addition & 2 deletions scripts/github-ci-pre.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -17,5 +18,3 @@ brew bundle install
# Install build dependencies
./scripts/build.sh installdeps

# Install additional CI dependencies
gem install trainer
17 changes: 2 additions & 15 deletions scripts/github-ci-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/^[ ]+//')

Expand Down
3 changes: 1 addition & 2 deletions scripts/github-ci-testbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7706a41

Please sign in to comment.