Skip to content

Commit 06f5d2c

Browse files
authored
Adopt GitHub workflows (#76)
* Adopt github workflows * Build tests in release mode and swiftlint in debug mode
1 parent 8b1fb1d commit 06f5d2c

17 files changed

+207
-212
lines changed

.github/workflows/ci.yaml

Lines changed: 67 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,97 @@
1-
# Copyright 2024-2025 Apple Inc. and the Swift Homomorphic Encryption project authors
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
151
name: CI
162
permissions:
173
contents: read
184
on:
195
workflow_dispatch:
206
push:
21-
branches: [ "main" ]
7+
branches: ["main", "release/**"]
228
pull_request:
23-
branches: [ "main" ]
9+
branches: ["main", "release/**"]
2410
types: [opened, reopened, synchronize]
2511
# Pushing changes to PR stops currently-running CI
2612
concurrency:
2713
group: ${{ github.workflow }}-${{ github.ref }}
2814
cancel-in-progress: true
2915
env:
30-
SWIFTLINT_VERSION: 0.57.0
31-
SWIFTFORMAT_VERSION: 0.54.6
16+
SWIFTLINT_VERSION: 0.58.2
17+
SWIFTFORMAT_VERSION: 0.55.5
3218
jobs:
33-
swift-tests:
34-
timeout-minutes: 15
35-
runs-on: ubuntu-latest
36-
strategy:
37-
fail-fast: false
38-
matrix:
39-
swift_version: ['6.0']
40-
os_version: ['jammy']
41-
container:
42-
image: swift:${{ matrix.swift_version }}-${{ matrix.os_version }}
43-
name: swift ${{ matrix.swift_version }} tests
44-
steps:
45-
- name: Swift version
46-
run: swift --version
47-
- name: Checkout repository
48-
uses: actions/checkout@v4
49-
- name: Run tests
50-
run: swift test --configuration release --parallel
19+
soundness:
20+
name: soundness
21+
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
22+
with:
23+
# https://github.com/swiftlang/swift-package-manager/issues/8103
24+
api_breakage_check_enabled: false
25+
format_check_enabled: false
26+
tests:
27+
name: swifttests
28+
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
29+
with:
30+
# https://github.com/apple/swift-distributed-tracing/issues/165
31+
enable_windows_checks: false
32+
linux_exclude_swift_versions: "[{\"swift_version\": \"5.9\"}, {\"swift_version\": \"5.10\"}]"
33+
linux_build_command: "swift test --configuration release"
5134
pre-commit:
5235
timeout-minutes: 1
5336
runs-on: ubuntu-latest
5437
steps:
55-
- name: Checkout repository
56-
uses: actions/checkout@v4
57-
- name: Install pre-commit
58-
run: pip install pre-commit
59-
- name: Pre-commit checks
60-
# CI will commit to `main`
61-
# swiftformat, swiftlint and license checks tested separately
62-
run: >
63-
SKIP=no-commit-to-branch,check-doc-comments,lockwood-swiftformat,swiftlint,insert-license
64-
pre-commit run --all-files
38+
- name: Checkout repository
39+
uses: actions/checkout@v4
40+
- name: Install pre-commit
41+
run: pip install pre-commit
42+
- name: Pre-commit checks
43+
# CI will commit to `main`
44+
# swiftformat, swiftlint and license checks tested separately
45+
run: >
46+
SKIP=no-commit-to-branch,check-doc-comments,lockwood-swiftformat,swiftlint,insert-license
47+
pre-commit run --all-files
6548
insert-license:
6649
timeout-minutes: 1
6750
runs-on: ubuntu-latest
6851
steps:
69-
- name: Checkout repository
70-
uses: actions/checkout@v4
71-
with:
72-
fetch-depth: 2
73-
- name: Install pre-commit
74-
run: pip install pre-commit
75-
- name: List changed files
76-
run: git diff --name-only HEAD~1
77-
- name: Run license check
78-
run: pre-commit run insert-license --files $(git diff --name-only HEAD~1)
52+
- name: Checkout repository
53+
uses: actions/checkout@v4
54+
with:
55+
fetch-depth: 2
56+
- name: Install pre-commit
57+
run: pip install pre-commit
58+
- name: List changed files
59+
run: git diff --name-only HEAD~1
60+
- name: Run license check
61+
run: pre-commit run insert-license --files $(git diff --name-only HEAD~1)
7962
lint:
8063
timeout-minutes: 15
8164
runs-on: ubuntu-latest
8265
steps:
83-
- name: Checkout repository
84-
uses: actions/checkout@v4
85-
- name: Cache SwiftLint
86-
id: cache-swiftlint
87-
uses: actions/cache@v4
88-
with:
89-
path: /tmp/swiftlint/SwiftLint/.build/release/swiftlint
90-
key: ${{ runner.os }}-swiftlint-${{ env.SWIFTLINT_VERSION }}
91-
- name: Install SwiftLint
92-
if: steps.cache-swiftlint.outputs.cache-hit != 'true'
93-
run: |
94-
ci/install-swiftlint.sh
95-
- name: Run SwiftLint
96-
run: /tmp/swiftlint/SwiftLint/.build/release/swiftlint lint --strict .
66+
- name: Checkout repository
67+
uses: actions/checkout@v4
68+
- name: Cache SwiftLint
69+
id: cache-swiftlint
70+
uses: actions/cache@v4
71+
with:
72+
path: /tmp/swiftlint/SwiftLint/.build/debug/swiftlint
73+
key: ${{ runner.os }}-swiftlint-${{ env.SWIFTLINT_VERSION }}
74+
- name: Install SwiftLint
75+
if: steps.cache-swiftlint.outputs.cache-hit != 'true'
76+
run: |
77+
ci/install-swiftlint.sh
78+
- name: Run SwiftLint
79+
run: /tmp/swiftlint/SwiftLint/.build/debug/swiftlint lint --strict .
9780
lockwood-swiftformat:
9881
timeout-minutes: 5
9982
runs-on: ubuntu-latest
10083
steps:
101-
- name: Checkout repository
102-
uses: actions/checkout@v4
103-
- name: Cache SwiftFormat
104-
id: cache-swiftformat
105-
uses: actions/cache@v4
106-
with:
107-
path: /tmp/swiftformat/SwiftFormat/.build/release/swiftformat
108-
key: ${{ runner.os }}-swiftformat-${{ env.SWIFTFORMAT_VERSION }}
109-
- name: Install Lockwood SwiftFormat
110-
if: steps.cache-swiftformat.outputs.cache-hit != 'true'
111-
run: |
112-
ci/install-lockwood-swiftformat.sh
113-
- name: Run SwiftFormat
114-
run: /tmp/swiftformat/SwiftFormat/.build/release/swiftformat --strict .
84+
- name: Checkout repository
85+
uses: actions/checkout@v4
86+
- name: Cache SwiftFormat
87+
id: cache-swiftformat
88+
uses: actions/cache@v4
89+
with:
90+
path: /tmp/swiftformat/SwiftFormat/.build/release/swiftformat
91+
key: ${{ runner.os }}-swiftformat-${{ env.SWIFTFORMAT_VERSION }}
92+
- name: Install Lockwood SwiftFormat
93+
if: steps.cache-swiftformat.outputs.cache-hit != 'true'
94+
run: |
95+
ci/install-lockwood-swiftformat.sh
96+
- name: Run SwiftFormat
97+
run: /tmp/swiftformat/SwiftFormat/.build/release/swiftformat --strict .

.license_header_template

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@@ Copyright YEARS Apple Inc. and the Swift Homomorphic Encryption project authors
2+
@@
3+
@@ Licensed under the Apache License, Version 2.0 (the "License");
4+
@@ you may not use this file except in compliance with the License.
5+
@@ You may obtain a copy of the License at
6+
@@
7+
@@ http://www.apache.org/licenses/LICENSE-2.0
8+
@@
9+
@@ Unless required by applicable law or agreed to in writing, software
10+
@@ distributed under the License is distributed on an "AS IS" BASIS,
11+
@@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
@@ See the License for the specific language governing permissions and
13+
@@ limitations under the License.

.licenseignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
**/.swiftformat
2+
*.pb.swift
3+
*.png
4+
.gitignore
5+
.swiftformat
6+
Package.resolved
7+
Package.swift
8+
Snippets/*

.pre-commit-config.yaml

Lines changed: 35 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,54 @@
1-
# Copyright 2024-2025 Apple Inc. and the Swift Homomorphic Encryption project authors
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
151
repos:
16-
- repo: https://github.com/pre-commit/pre-commit-hooks
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
173
rev: v5.0.0
184
hooks:
19-
- id: check-case-conflict
20-
- id: check-merge-conflict
21-
- id: check-symlinks
22-
- id: fix-byte-order-marker
23-
- id: check-toml
24-
- id: check-yaml
5+
- id: check-case-conflict
6+
- id: check-merge-conflict
7+
- id: check-symlinks
8+
- id: fix-byte-order-marker
9+
- id: check-toml
10+
- id: check-yaml
2511
args: [--allow-multiple-documents]
26-
- id: end-of-file-fixer
27-
- id: mixed-line-ending
28-
- id: no-commit-to-branch
12+
- id: end-of-file-fixer
13+
- id: mixed-line-ending
14+
- id: no-commit-to-branch
2915
args: [--branch, main]
30-
- id: trailing-whitespace
31-
- repo: https://github.com/Lucas-C/pre-commit-hooks
16+
- id: trailing-whitespace
17+
- repo: https://github.com/Lucas-C/pre-commit-hooks
3218
rev: v1.5.5
3319
hooks:
34-
- id: insert-license
20+
- id: insert-license
3521
name: insert-license
3622
'types_or': [c, swift, proto]
3723
args:
38-
- --license-filepath
39-
- copyright-header.txt
40-
- --comment-style
41-
- //
42-
- --allow-past-years
43-
- --use-current-year
44-
- --detect-license-in-X-top-lines=10
45-
- id: insert-license
46-
name: insert-license-yaml
47-
'types_or': [yaml]
24+
- --license-filepath
25+
- copyright-header.txt
26+
- --comment-style
27+
- //
28+
- --allow-past-years
29+
- --use-current-year
30+
- --detect-license-in-X-top-lines=10
31+
- id: insert-license
32+
name: insert-license-sh
33+
types_or: [shell]
4834
args:
49-
- --license-filepath
50-
- copyright-header.txt
51-
- --allow-past-years
52-
- --use-current-year
53-
- repo: local
35+
- --license-filepath
36+
- copyright-header.txt
37+
- --comment-style
38+
- "##"
39+
- --allow-past-years
40+
- --use-current-year
41+
- repo: local
5442
hooks:
55-
# Note, this is https://github.com/nicklockwood/SwiftFormat, not
56-
# https://github.com/apple/swift-format
57-
- id: lockwood-swiftformat
43+
# Note, this is https://github.com/nicklockwood/SwiftFormat, not
44+
# https://github.com/apple/swift-format
45+
- id: lockwood-swiftformat
5846
name: lockwood-swiftformat
5947
entry: swiftformat
6048
language: system
6149
types: [swift]
62-
# https://github.com/realm/SwiftLint
63-
- id: swiftlint
50+
# https://github.com/realm/SwiftLint
51+
- id: swiftlint
6452
name: swiftlint
6553
entry: swiftlint lint --strict
6654
language: system

.spi.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,3 @@
1-
# Copyright 2024 Apple Inc. and the Swift Homomorphic Encryption project authors
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
151
version: 1
162
builder:
173
configs:

.swiftformat

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,4 @@
77
--nospaceoperators ..<, ...
88
--ranges no-space
99
--self init-only
10-
--swiftversion 5.8
11-
--asynccapturing XCTAssertAsyncThrowsError
10+
--swiftversion 6.0

.swiftlint.yml

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,21 @@
1-
# Copyright 2024 Apple Inc. and the Swift Homomorphic Encryption project authors
2-
#
3-
# Licensed under the Apache License, Version 2.0 (the "License");
4-
# you may not use this file except in compliance with the License.
5-
# You may obtain a copy of the License at
6-
#
7-
# http://www.apache.org/licenses/LICENSE-2.0
8-
#
9-
# Unless required by applicable law or agreed to in writing, software
10-
# distributed under the License is distributed on an "AS IS" BASIS,
11-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
# See the License for the specific language governing permissions and
13-
# limitations under the License.
14-
151
disabled_rules:
162
- cyclomatic_complexity
173
- file_length
184
- function_body_length
195
- identifier_name
20-
- opening_brace # conflicts with swiftformat
6+
- opening_brace # conflicts with swiftformat
217
- todo
22-
- trailing_comma # conflicts with swiftformat
8+
- trailing_comma # conflicts with swiftformat
239
- type_body_length
24-
- vertical_parameter_alignment_on_call # conflicts with swiftformat
25-
- file_header # pre-commit deals with license header
26-
- raw_value_for_camel_cased_codable_enum # conflicts with swiftformat
27-
28-
excluded:
29-
- "**/*pb.swift"
30-
- "**/.build/"
31-
10+
- vertical_parameter_alignment_on_call # conflicts with swiftformat
11+
- file_header # pre-commit deals with license header
12+
- raw_value_for_camel_cased_codable_enum # conflicts with swiftformat
13+
excluded: ['**/*pb.swift', '**/.build/']
3214
line_length:
3315
warning: 120
3416
ignores_urls: true
35-
3617
closure_body_length:
3718
warning: 40
38-
3919
opt_in_rules:
4020
- accessibility_label_for_image
4121
- accessibility_trait_for_button
@@ -139,7 +119,6 @@ opt_in_rules:
139119
- weak_delegate
140120
- xct_specific_matcher
141121
- yoda_condition
142-
143122
# Disabled rules
144123
# Deprecated or requires running analyzer
145124
# - anyobject_protocol

.yamllint.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extends: default
2+
rules:
3+
line-length: false
4+
document-start: false
5+
truthy:
6+
check-keys: false # Otherwise we get a false positive on GitHub action's `on` key
7+
ignore: [.build, .index-build]

0 commit comments

Comments
 (0)