-
Notifications
You must be signed in to change notification settings - Fork 32
131 lines (130 loc) · 4.22 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Copyright 2024-2025 Apple Inc. and the Swift Homomorphic Encryption project authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: CI
permissions:
contents: read
on:
workflow_dispatch:
push:
branches: [ "main", "release/**" ]
pull_request:
branches: [ "main", "release/**" ]
types: [opened, reopened, synchronize]
# Pushing changes to PR stops currently-running CI
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Keep versions in sync with README
env:
SWIFTLINT_VERSION: 0.55.1
SWIFTFORMAT_VERSION: 0.54.0
jobs:
swift-tests:
timeout-minutes: 15
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
swift_version: ['5.10', '6.0']
os_version: ['jammy']
container:
image: swift:${{ matrix.swift_version }}-${{ matrix.os_version }}
name: swift ${{ matrix.swift_version }} tests
steps:
- name: Swift version
run: swift --version
- name: Checkout repository
uses: actions/checkout@v4
- name: Install jemalloc
run: apt-get update && apt-get install -y libjemalloc-dev
- name: Run tests
run: swift test --configuration release --parallel
- name: Run snippets
run: >
for filename in $(find Snippets -name \*.swift); do
basename=$(basename "$filename" .swift)
swift run --configuration release ${basename}
done
pre-commit:
timeout-minutes: 1
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install pre-commit
run: pip install pre-commit
- name: Pre-commit checks
# CI will commit to `main`
# swiftformat, swiftlint and license checks tested separately
run: >
SKIP=no-commit-to-branch,lockwood-swiftformat,swiftlint,check-doc-comments,insert-license
pre-commit run --all-files
insert-license:
timeout-minutes: 1
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Install pre-commit
run: pip install pre-commit
- name: List changed files
run: git diff --name-only HEAD~1
- name: Run license check
run: pre-commit run insert-license --files $(git diff --name-only HEAD~1)
lint:
timeout-minutes: 15
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache SwiftLint
id: cache-swiftlint
uses: actions/cache@v4
with:
path: /tmp/swiftlint/SwiftLint/.build/release/swiftlint
key: ${{ runner.os }}-swiftlint-${{ env.SWIFTLINT_VERSION }}
- name: Install SwiftLint
if: steps.cache-swiftlint.outputs.cache-hit != 'true'
run: |
ci/install-swiftlint.sh
- name: Run SwiftLint
run: /tmp/swiftlint/SwiftLint/.build/release/swiftlint lint --strict .
lockwood-swiftformat:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Cache SwiftFormat
id: cache-swiftformat
uses: actions/cache@v4
with:
path: /tmp/swiftformat/SwiftFormat/.build/release/swiftformat
key: ${{ runner.os }}-swiftformat-${{ env.SWIFTFORMAT_VERSION }}
- name: Install Lockwood SwiftFormat
if: steps.cache-swiftformat.outputs.cache-hit != 'true'
run: |
ci/install-lockwood-swiftformat.sh
- name: Run SwiftFormat
run: /tmp/swiftformat/SwiftFormat/.build/release/swiftformat --strict .
check-doc-comments:
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check documentation comments
run: ci/run-apple-swift-format.sh