ci: add CI for YAML files #2
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: ci | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
container: swiftlang/swift:nightly-6.1-jammy | |
outputs: | |
SUMMARY: ${{ steps.summary.outputs.SUMMARY }} | |
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 --parallel | |
- name: llvm-cov report | |
id: report | |
run: | | |
echo 'OUTPUT<<EOF' >> "$GITHUB_OUTPUT" | |
llvm-cov report .build/debug/zyphyPackageTests.xctest --instr-profile=.build/debug/codecov/default.profdata --ignore-filename-regex=".build|Tests|TokenizerMacros" --show-region-summary=false --show-branch-summary=false >> "$GITHUB_OUTPUT" | |
echo 'EOF' >> "$GITHUB_OUTPUT" | |
- name: Create summary text | |
id: summary | |
env: | |
REPORT_OUTPUT: ${{ steps.report.outputs.OUTPUT }} | |
run: | | |
echo 'SUMMARY<<EOF' >> "$GITHUB_OUTPUT" | |
echo '## Coverage Summary' >> "$GITHUB_OUTPUT" | |
echo >> "$GITHUB_OUTPUT" | |
echo "$(date)" >> "$GITHUB_OUTPUT" | |
echo >> "$GITHUB_OUTPUT" | |
echo '```' >> "$GITHUB_OUTPUT" | |
echo "$REPORT_OUTPUT" >> "$GITHUB_OUTPUT" | |
echo '```' >> "$GITHUB_OUTPUT" | |
echo 'EOF' >> "$GITHUB_OUTPUT" | |
- name: Create a job summary | |
env: | |
SUMMARY: ${{ steps.summary.outputs.SUMMARY }} | |
run: echo "$SUMMARY" >> "$GITHUB_STEP_SUMMARY" | |
comment-test: | |
needs: test | |
runs-on: ubuntu-latest | |
container: swiftlang/swift:nightly-6.1-jammy | |
continue-on-error: true | |
steps: | |
- name: Comment PR | |
if: ${{ github.ref != 'refs/heads/main' }} | |
uses: thollander/actions-comment-pull-request@v3 | |
with: | |
message: ${{ needs.test.outputs.SUMMARY }} | |
comment-tag: coverage | |
lint: | |
runs-on: ubuntu-latest | |
container: swiftlang/swift:nightly-6.1-jammy | |
steps: | |
- uses: actions/checkout@v4 | |
- run: swift format lint -rsp . | |
benchmark: | |
if: ${{ github.ref != 'refs/heads/main' }} | |
needs: test | |
runs-on: ubuntu-latest | |
container: swiftlang/swift:nightly-6.1-jammy | |
outputs: | |
SUMMARY: ${{ steps.summary.outputs.SUMMARY }} | |
steps: | |
- uses: actions/checkout@v4 | |
- run: apt-get update && apt-get install --no-install-recommends -y libjemalloc-dev | |
- uses: actions/cache@v4 | |
with: | |
path: Benchmarks/.build | |
key: ${{ runner.os }}-bench-spm-${{ hashFiles('Benchmarks/Package.resolved') }} | |
restore-keys: | | |
${{ runner.os }}-bench-spm- | |
- 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 | |
id: check | |
run: | | |
set +e | |
echo 'OUTPUT<<EOF' >> "$GITHUB_OUTPUT" | |
swift package --package-path Benchmarks benchmark baseline check main pull_request --format markdown >> "$GITHUB_OUTPUT" | |
echo 'EOF' >> "$GITHUB_OUTPUT" | |
- name: swift package benchmark baseline compare | |
id: compare | |
run: | | |
echo 'OUTPUT<<EOF' >> "$GITHUB_OUTPUT" | |
swift package --package-path Benchmarks benchmark baseline compare main pull_request --no-progress --quiet --format markdown >> "$GITHUB_OUTPUT" | |
echo 'EOF' >> "$GITHUB_OUTPUT" | |
- name: Create summary text | |
id: summary | |
env: | |
CHECK_OUTPUT: ${{ steps.check.outputs.OUTPUT }} | |
COMPARE_OUTPUT: ${{ steps.compare.outputs.OUTPUT }} | |
run: | | |
echo 'SUMMARY<<EOF' >> "$GITHUB_OUTPUT" | |
echo '## Benchmark Summary' >> "$GITHUB_OUTPUT" | |
echo >> "$GITHUB_OUTPUT" | |
echo "$(date)" >> "$GITHUB_OUTPUT" | |
echo >> "$GITHUB_OUTPUT" | |
echo "$CHECK_OUTPUT" >> "$GITHUB_OUTPUT" | |
echo >> "$GITHUB_OUTPUT" | |
echo '---' >> "$GITHUB_OUTPUT" | |
echo >> "$GITHUB_OUTPUT" | |
echo "$COMPARE_OUTPUT" >> "$GITHUB_OUTPUT" | |
echo 'EOF' >> "$GITHUB_OUTPUT" | |
- name: Create a job summary | |
env: | |
SUMMARY: ${{ steps.summary.outputs.SUMMARY }} | |
run: echo "$SUMMARY" >> "$GITHUB_STEP_SUMMARY" | |
comment-benchmark: | |
needs: benchmark | |
runs-on: ubuntu-latest | |
container: swiftlang/swift:nightly-6.1-jammy | |
continue-on-error: true | |
steps: | |
- name: Comment PR | |
uses: thollander/actions-comment-pull-request@v3 | |
with: | |
message: ${{ needs.benchmark.outputs.SUMMARY }} | |
comment-tag: benchmark | |
yamllint: | |
runs-on: ubuntu-latest | |
container: alpine:3.21 | |
steps: | |
- uses: actions/checkout@v4 | |
- run: apk update && apk add yamllint | |
- run: yamllint --version | |
- run: yamllint --strict --config-file .yamllint.yml . |