ci: run benchmarks (#62) #557
Workflow file for this run
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
name: Swift | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
container: swiftlang/swift:nightly-6.0-jammy | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
- uses: actions/cache@v4 | |
with: | |
path: .build | |
key: ${{ runner.os }}-spm-${{ hashFiles('Package.resolved') }} | |
restore-keys: | | |
${{ runner.os }}-spm- | |
- run: swift --version | |
- run: swift build --build-tests --disable-xctest --enable-code-coverage | |
- run: swift test --skip-build --disable-xctest --enable-code-coverage | |
# FIXME: `grep -v 184467440737095` is a workaround for octocov parse error | |
- run: llvm-cov export --format=lcov .build/debug/zyphyPackageTests.xctest --instr-profile .build/debug/codecov/default.profdata --ignore-filename-regex=".build|Tests|TokenizerMacros" | grep -v 184467440737095 > coverage_report.lcov | |
- uses: k1LoW/octocov-action@v1 | |
lint: | |
runs-on: ubuntu-latest | |
container: swiftlang/swift:nightly-6.0-jammy | |
steps: | |
- uses: actions/checkout@v4 | |
- run: swift format lint -rs . | |
benchmark: | |
if: ${{ github.ref != 'refs/heads/main' }} | |
needs: test | |
runs-on: ubuntu-latest | |
container: swiftlang/swift:nightly-6.0-jammy | |
steps: | |
- uses: actions/checkout@v4 | |
- run: apt-get update && apt-get install --no-install-recommends -y libjemalloc-dev | |
- run: swift package --package-path Benchmarks benchmark baseline update pull_request --no-progress --quiet | |
- name: Switch to branch 'main' | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
clean: false | |
- run: swift package --package-path Benchmarks benchmark baseline update main --no-progress --quiet | |
- name: swift package benchmark baseline check | |
continue-on-error: true | |
run: | | |
echo '## Benchmark Summary' >> "$GITHUB_STEP_SUMMARY" | |
echo "$(date)" >> "$GITHUB_STEP_SUMMARY" | |
swift package --package-path Benchmarks benchmark baseline check main pull_request --format markdown >> "$GITHUB_STEP_SUMMARY" | |
- name: swift package benchmark baseline compare | |
run: | | |
echo >> "$GITHUB_STEP_SUMMARY" | |
echo '---' >> "$GITHUB_STEP_SUMMARY" | |
swift package --package-path Benchmarks benchmark baseline compare main pull_request --no-progress --quiet --format markdown >> "$GITHUB_STEP_SUMMARY" | |
- name: Pull request comment text | |
id: prtest | |
run: | | |
echo 'PRTEST<<EOF' >> "$GITHUB_OUTPUT" | |
cat "$GITHUB_STEP_SUMMARY" >> "$GITHUB_OUTPUT" | |
echo 'EOF' >> "$GITHUB_OUTPUT" | |
- name: Comment PR | |
uses: thollander/actions-comment-pull-request@v3 | |
with: | |
message: ${{ steps.prtest.outputs.PRTEST }} | |
comment-tag: benchmark |