Skip to content

Commit

Permalink
ci: 🔄 Synced file(s) with ordo-one/public-repository-templates (#42)
Browse files Browse the repository at this point in the history
Synced local file(s) with
[ordo-one/public-repository-templates](https://github.com/ordo-one/public-repository-templates).
  • Loading branch information
ordo-ci authored Dec 12, 2022
1 parent a47f7e3 commit 780bce5
Show file tree
Hide file tree
Showing 15 changed files with 511 additions and 30 deletions.
13 changes: 13 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Description

Include a summary of the change and which issue is fixed. Please also include relevant motivation and context.

## How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

## Minimal checklist:

- [ ] I have performed a self-review of my own code
- [ ] I have added `DocC` code-level documentation for any public interfaces exported by the package
- [ ] I have added unit and/or integration tests that prove my fix is effective or that my feature works
61 changes: 61 additions & 0 deletions .github/workflows/lint-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: "PR title validation"

on:
pull_request_target:
types:
- opened
- edited
- synchronize

jobs:
main:
name: Validate PR title
runs-on: [ubuntu-latest]
steps:
- uses: amannn/action-semantic-pull-request@v4
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# Configure which types are allowed.
# Default: https://github.com/commitizen/conventional-commit-types
types: |
fix
feat
docs
style
refactor
perf
test
build
ci
chore
revert
# Configure which scopes are allowed.
scopes: |
core
ui
# Configure that a scope must always be provided.
requireScope: false
# Configure which scopes are disallowed in PR titles. For instance by setting
# the value below, `chore(release): ...` and `ci(e2e,release): ...` will be rejected.
disallowScopes: |
release
# Configure additional validation for the subject based on a regex.
# This example ensures the subject doesn't start with an uppercase character.
#subjectPattern: ^.*\[sc-[0-9]+\].*$
#subjectPatternError: |
# The pull request title should contain Shortcut case number like '[sc-123]'
# If the PR contains one of these labels, the validation is skipped.
# Multiple labels can be separated by newlines.
# If you want to rerun the validation when labels change, you might want
# to use the `labeled` and `unlabeled` event triggers in your workflow.
ignoreLabels: |
bot
ignore-semantic-pull-request
# For work-in-progress PRs you can typically use draft pull requests
# from GitHub. However, private repositories on the free plan don't have
# this option and therefore this action allows you to opt-in to using the
# special "[WIP]" prefix to indicate this state. This will avoid the
# validation of the PR title and the pull request checks remain pending.
# Note that a second check will be reported if this is enabled.
wip: true
88 changes: 88 additions & 0 deletions .github/workflows/swift-benchmark-delta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Benchmark PR vs main

on:
workflow_dispatch:
pull_request:
branches: [ main ]

jobs:
benchmark-delta:

runs-on: ${{ matrix.os }}
continue-on-error: true

strategy:
matrix:
#os: [[Linux, benchmark-swift-latest, self-hosted]]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Homebrew Mac
if: ${{ runner.os == 'Macos' }}
run: |
echo "/opt/homebrew/bin:/usr/local/bin" >> $GITHUB_PATH
brew install jemalloc
- name: Ubuntu deps
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt-get install -y libjemalloc-dev
- name: Git URL token override and misc
run: |
#git config --global url."https://ordo-ci:${{ secrets.CI_MACHINE_PAT }}@github.com".insteadOf "https://github.com"
#/usr/bin/ordo-performance
[ -d Benchmarks ] && echo "hasBenchmark=1" >> $GITHUB_ENV
echo "/opt/homebrew/bin:/usr/local/bin" >> $GITHUB_PATH
- name: Run benchmarks for PR branch
if: ${{ env.hasBenchmark == '1' }}
run: |
swift package --allow-writing-to-directory .benchmarkBaselines/ benchmark update-baseline pull_request
- name: Switch to branch 'main'
if: ${{ env.hasBenchmark == '1' }}
run: |
git stash
git checkout main
- name: Run benchmarks for branch 'main'
if: ${{ env.hasBenchmark == '1' }}
run: |
swift package --allow-writing-to-directory .benchmarkBaselines/ benchmark update-baseline main
- name: Compare PR and main
if: ${{ env.hasBenchmark == '1' }}
id: benchmark
run: |
echo $(date) >> $GITHUB_STEP_SUMMARY
echo "exitStatus=1" >> $GITHUB_ENV
swift package benchmark compare main pull_request --format markdown >> $GITHUB_STEP_SUMMARY
echo "exitStatus=0" >> $GITHUB_ENV
continue-on-error: true
- if: ${{ env.exitStatus == '0' }}
name: Pull request comment text success
id: prtestsuccess
run: |
echo 'PRTEST<<EOF' >> $GITHUB_ENV
echo "[Pull request benchmark comparison [${{ matrix.os }}] with 'main' run at $(date -Iseconds)](https://github.com/ordo-one/${{ github.event.repository.name }}/actions/runs/${{ github.run_id }})" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- if: ${{ env.exitStatus == '1' }}
name: Pull request comment text failure
id: prtestfailure
run: |
echo 'PRTEST<<EOF' >> $GITHUB_ENV
echo "[Pull request benchmark comparison [${{ matrix.os }}] with 'main' run at $(date -Iseconds)](https://github.com/ordo-one/${{ github.event.repository.name }}/actions/runs/${{ github.run_id }})" >> $GITHUB_ENV
echo "_Pull request had performance regressions_" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
- name: Comment PR
if: ${{ env.hasBenchmark == '1' }}
uses: thollander/actions-comment-pull-request@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
message: ${{ env.PRTEST }}
comment_includes: "Pull request benchmark comparison [${{ matrix.os }}] with"
- name: Exit with correct status
run: |
#/usr/bin/ordo-performance powersave
exit ${{ env.exitStatus }}
32 changes: 32 additions & 0 deletions .github/workflows/swift-check-api-breaks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Swift check API breaks

on:
workflow_dispatch:
pull_request:
types: [opened, synchronize]

jobs:
analyze-api-breakage:

runs-on: [ubuntu-latest]
timeout-minutes: 30

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Ubuntu deps
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt-get install -y libjemalloc-dev
- name: Extract default SPM library target
id: spm_target
run: |
SPM_DEFAULT_TARGET=$(swift package dump-package | jq -r '.products | .[] | select(.type | has("library")) | .name' | head -1)
echo "spmlibrarytarget=${SPM_DEFAULT_TARGET}" >> $GITHUB_ENV
- name: Build
if: ${{ env.spmlibrarytarget }}
run: swift build
- name: Analyze API breakage
if: ${{ env.spmlibrarytarget }}
run: swift package diagnose-api-breaking-changes origin/main --targets ${{ env.spmlibrarytarget }}
43 changes: 27 additions & 16 deletions .github/workflows/swift-code-coverage.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,42 @@
name: Code coverage
name: Swift code coverage

on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build-test-and-upload-test-coverage:
# Only on Linux as macOS doesn't support jemalloc interposition when running unit tests
runs-on: ubuntu-latest

test-code-coverage:
runs-on: [ubuntu-22.04]
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- name: Install jemalloc Linux
run: sudo apt-get install -y libjemalloc-dev

- name: Ubuntu deps
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt-get install -y libjemalloc-dev llvm-14
- name: Run tests
run: swift test --enable-code-coverage
- name: Set path
run: echo "/usr/lib/llvm-9/bin" >> $GITHUB_PATH
- name: Install LLVM and Clang
uses: KyleMayes/install-llvm-action@v1
with:
version: "13"
continue-on-error: true
run: |
[ -d Tests ] && swift test --parallel --enable-code-coverage
- name: Export code coverage
run: llvm-cov export -format="lcov" .build/debug/BenchmarkPackageTests.xctest -instr-profile .build/debug/codecov/default.profdata > info.lcov
run: |
xctest_binary=".build/debug/${{ github.event.repository.name }}PackageTests.xctest"
if [ ! -f ${xctest_binary} ]; then
xctest_binary=$(find .build/debug/ -type f -name "*.xctest" | tail -1)
echo "Will llvm-cov '${xctest_binary}'"
fi
if [ -f ${xctest_binary} ]; then
llvm-cov-14 export -format="lcov" ${xctest_binary} -instr-profile .build/debug/codecov/default.profdata > info.lcov
fi
- name: Upload codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_REPO_TOKEN }}
files: info.lcov
3 changes: 2 additions & 1 deletion .github/workflows/swift-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ on:

jobs:
SwiftLint:
runs-on: ubuntu-latest
timeout-minutes: 60
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v3
- name: GitHub Action for SwiftLint with --strict
Expand Down
36 changes: 36 additions & 0 deletions .github/workflows/swift-linux-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Swift Linux build

on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build-linux:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]

timeout-minutes: 60
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v3

- name: Ubuntu deps
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt-get install -y libjemalloc-dev
- name: Swift version
run: swift --version

- name: Build
run: swift build

- name: Run tests
run: |
[ -d Tests ] && swift test --parallel
28 changes: 28 additions & 0 deletions .github/workflows/swift-macos-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Swift macOS build

on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build-macos:
timeout-minutes: 60
runs-on: [macos-12]

steps:
- name: Homebrew Mac
if: ${{ runner.os == 'Macos' }}
run: |
echo "/opt/homebrew/bin:/usr/local/bin" >> $GITHUB_PATH
brew install jemalloc
- uses: actions/checkout@v3
- name: Swift version
run: swift --version
- name: Build
run: swift build
- name: Run tests
run: |
[ -d Tests ] && swift test --parallel
28 changes: 28 additions & 0 deletions .github/workflows/swift-outdated-dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Swift outdated dependencies

on:
workflow_dispatch:
schedule:
- cron: '0 8 * * 1' # every monday AM 8:00

jobs:
spm-dep-check:
runs-on: [ubuntu-latest]
timeout-minutes: 60
steps:
- uses: actions/checkout@v3
- name: Check Swift package dependencies
id: spm-dep-check
uses: MarcoEidinger/[email protected]
with:
isMutating: true
failWhenOutdated: false
- name: Create Pull Request
if: steps.spm-dep-check.outputs.outdatedDependencies == 'true'
uses: peter-evans/create-pull-request@v3
with:
commit-message: 'chore: update package dependencies'
branch: updatePackageDepedencies
delete-branch: true
title: 'chore: update package dependencies'
body: ${{ steps.spm-dep-check.outputs.releaseNotes }}
Loading

0 comments on commit 780bce5

Please sign in to comment.