-
Notifications
You must be signed in to change notification settings - Fork 0
92 lines (88 loc) · 2.83 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: CI
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
get_os:
name: Determine supported OS
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check and output correct matrix
id: output_data
run: |
macos='macOS-latest'
if [ -e .github/macos_version.txt ]
then
macos=$(cat ./.github/macos_version.txt)
fi
if [ -e .github/macos_only ]
then
echo "os_matrix=['$macos']" >> $GITHUB_OUTPUT
echo "coverage_os=$macos" >> $GITHUB_OUTPUT
else
echo "os_matrix=['$macos', 'ubuntu-latest']" >> $GITHUB_OUTPUT
echo "coverage_os=ubuntu-latest" >> $GITHUB_OUTPUT
fi
outputs:
os_matrix: ${{ steps.output_data.outputs.os_matrix }}
coverage_os: ${{ steps.output_data.outputs.coverage_os }}
test:
name: Tests
needs: get_os
strategy:
matrix:
os: ${{fromJson(needs.get_os.outputs.os_matrix)}}
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Swift
uses: swift-actions/[email protected]
- name: Run tests
run: swift test --enable-code-coverage -Xswiftc -warnings-as-errors
- name: Save PR number
if: ${{ matrix.os == needs.get_os.outputs.coverage_os }}
run: |
mkdir -p ./pr
echo ${{ github.event.number }} > ./pr/NR
- name: Generate test coverage report
if: ${{ matrix.os == needs.get_os.outputs.coverage_os }}
uses: maxep/[email protected]
with:
output-file: ./pr/lcov.info
- name: Upload Coverage Information for Comment
if: ${{ matrix.os == needs.get_os.outputs.coverage_os }}
uses: actions/upload-artifact@v3
with:
name: pr
path: pr/
- name: 'Read minimum coverage'
if: ${{ matrix.os == needs.get_os.outputs.coverage_os }}
run: echo "minimum_coverage=$(cat ./.github/minimum_coverage.txt)" >> $GITHUB_ENV
- name: Enforce test coverage threshhold
if: ${{ matrix.os == needs.get_os.outputs.coverage_os }}
uses: VeryGoodOpenSource/[email protected]
with:
path: ./pr/lcov.info
min_coverage: ${{ env.minimum_coverage }}
swiftlint:
name: SwiftLint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Swift
uses: swift-actions/[email protected]
- name: Install SwiftLint
run: |
curl -L https://github.com/realm/SwiftLint/releases/download/0.52.4/swiftlint_linux.zip -o swiftlint.zip
unzip swiftlint.zip -d swiftlint
./swiftlint/swiftlint --version
- name: Run SwiftLint
run: ./swiftlint/swiftlint --strict --reporter github-actions-logging