Skip to content

Commit d14e22a

Browse files
authored
Migrate Linux builds from Azure to GitHub Actions (#6132)
This allows for better reusability and integration. macOS builds still run on Azure due to GitHub's limitation of up to 5 macOS jobs running concurrently.
1 parent 4b9208a commit d14e22a

File tree

8 files changed

+121
-78
lines changed

8 files changed

+121
-78
lines changed

.azure/templates/run-make.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Bazel Linux Build
2+
description: Common steps to build SwiftLint with Bazel on GitHub Linux runners
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Create ci.bazelrc file
7+
shell: bash
8+
run: echo "$CI_BAZELRC_FILE_CONTENT" | base64 -d > ci.bazelrc
9+
env:
10+
CI_BAZELRC_FILE_CONTENT: ${{ env.CI_BAZELRC_FILE_CONTENT }}
11+
- name: Apply patch
12+
shell: bash
13+
run: git apply --ignore-whitespace .bcr/patches/no-warnings-as-errors.patch
14+
- name: Build SwiftLint with Bazel
15+
shell: bash
16+
run: |
17+
export PATH="/usr/share/swift/usr/bin:$PATH"
18+
bazel build --config release //:swiftlint
19+
env:
20+
CC: clang
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Run Make Rule
2+
description: Runs a specified Makefile rule
3+
inputs:
4+
rule:
5+
description: The Makefile rule to run
6+
required: true
7+
default: build
8+
runs:
9+
using: composite
10+
steps:
11+
- run: |
12+
awk '
13+
$0 ~ "${{ inputs.rule }}:" { in_rule = 1; next }
14+
in_rule && /^\t/ { print $0 }
15+
in_rule && !/^\t/ { in_rule = 0 }
16+
' Makefile | while IFS= read -r command; do
17+
eval "$command"
18+
done
19+
shell: bash

.github/workflows/build.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Build
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
bazel_linux:
13+
name: Bazel, Linux, Swift 6.1 # pre-installed
14+
runs-on: ubuntu-24.04
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: ./.github/actions/bazel-linux-build
18+
name: Build SwiftLint with Bazel
19+
env:
20+
CI_BAZELRC_FILE_CONTENT: ${{ secrets.CI_BAZELRC_FILE_CONTENT }}
21+
22+
plugins_linux:
23+
name: SPM plugins, Linux, Swift ${{ matrix.version }}
24+
runs-on: ubuntu-24.04
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
include:
29+
- image: swift:5.9-focal
30+
version: '5.9'
31+
- image: swift:5.10-noble
32+
version: '5.10'
33+
- image: swift:6.0-noble
34+
version: '6.0'
35+
- image: swift:6.1-noble
36+
version: '6.1'
37+
container: ${{ matrix.image }}
38+
steps:
39+
- uses: actions/checkout@v4
40+
- name: Build plugins
41+
uses: ./.github/actions/run-make
42+
with:
43+
rule: spm_build_plugins

.github/workflows/lint.yml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,25 @@ name: Lint
22

33
on:
44
pull_request:
5-
branches:
6-
- '*'
75

86
permissions:
97
contents: read
108
pull-requests: write
119

1210
jobs:
1311
lint-swift:
14-
name: Lint Swift
12+
name: Swift
1513
runs-on: ubuntu-24.04 # "Noble Numbat"
1614
steps:
1715
- uses: actions/checkout@v4
18-
- name: Create ci.bazelrc file
19-
run: echo "$CI_BAZELRC_FILE_CONTENT" | base64 -d > ci.bazelrc
16+
- uses: ./.github/actions/bazel-linux-build
17+
name: Build SwiftLint with Bazel
2018
env:
2119
CI_BAZELRC_FILE_CONTENT: ${{ secrets.CI_BAZELRC_FILE_CONTENT }}
2220
- name: Lint
23-
run: |
24-
export PATH="/usr/share/swift/usr/bin:$PATH"
25-
git apply --ignore-whitespace .bcr/patches/no-warnings-as-errors.patch
26-
bazel build --config release //:swiftlint
27-
./bazel-bin/swiftlint lint --reporter github-actions-logging --strict 2> /dev/null
28-
env:
29-
CC: clang
21+
run: ./bazel-bin/swiftlint lint --reporter github-actions-logging --strict 2> /dev/null
3022
lint-markdown:
31-
name: Lint Markdown
23+
name: Markdown
3224
runs-on: ubuntu-24.04
3325
steps:
3426
- uses: actions/checkout@v4
@@ -40,7 +32,7 @@ jobs:
4032
CONTRIBUTING.md
4133
README.md
4234
lint-actions:
43-
name: Lint Actions
35+
name: Actions
4436
runs-on: ubuntu-24.04
4537
steps:
4638
- uses: actions/checkout@v4

.github/workflows/test.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
8+
permissions:
9+
contents: read
10+
11+
env:
12+
SKIP_INTEGRATION_TESTS: 'true'
13+
14+
jobs:
15+
spm_linux:
16+
name: SPM, Linux, Swift 6.1
17+
runs-on: ubuntu-24.04
18+
container: swift:6.1-noble
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions/cache@v4
22+
with:
23+
key: ${{ runner.os }}-swift-spm-${{ hashFiles('Package.resolved') }}
24+
restore-keys: ${{ runner.os }}-swift-spm-
25+
path: .build
26+
- name: Run SPM tests
27+
uses: ./.github/actions/run-make
28+
with:
29+
rule: spm_test

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Packages/
6363
bundle/
6464

6565
# Bazel
66-
bazel-*
66+
/bazel-*
6767
/MODULE.bazel.lock
6868

6969
# Danger

azure-pipelines.yml

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,16 @@ variables:
55
SKIP_INTEGRATION_TESTS: 'true'
66

77
jobs:
8-
- job: spm_linux
9-
displayName: 'SPM, Linux : Swift 6.1'
10-
pool:
11-
vmImage: 'ubuntu-24.04' # "Noble Numbat"
12-
container: swift:6.1-noble
13-
steps:
14-
- template: .azure/templates/run-make.yml
15-
parameters:
16-
rule: spm_test
17-
18-
- job: bazel_linux
19-
displayName: 'Bazel, Linux : Swift 6.0'
20-
pool:
21-
vmImage: 'ubuntu-24.04'
22-
steps:
23-
- script: |
24-
export PATH="/usr/share/swift/usr/bin:$PATH"
25-
git apply --ignore-whitespace .bcr/patches/no-warnings-as-errors.patch
26-
bazel build :swiftlint
27-
displayName: Build SwiftLint with Bazel
28-
env:
29-
CC: "clang"
30-
318
- job: tests_macos
329
displayName: 'Tests, macOS'
3310
strategy:
3411
maxParallel: '10'
3512
matrix:
36-
'14 : Xcode 15.4':
13+
'14, Xcode 15.4':
3714
image: 'macOS-14'
3815
xcode: '15.4'
39-
# '14 : Xcode 16.3': Runs on Buildkite.
40-
'15 : Xcode 16.4':
16+
# '14, Xcode 16.3': Runs on Buildkite.
17+
'15, Xcode 16.4':
4118
image: 'macOS-15'
4219
xcode: '16.4'
4320
pool:
@@ -48,27 +25,6 @@ jobs:
4825
- script: make spm_test
4926
displayName: Run tests
5027

51-
- job: plugins_linux # Plugins shall be able to run on older Swift versions.
52-
displayName: 'Plugins, Linux'
53-
pool:
54-
vmImage: 'ubuntu-24.04' # "Noble Numbat"
55-
strategy:
56-
maxParallel: '10'
57-
matrix:
58-
': Swift 5.9':
59-
image: swift:5.9-focal
60-
': Swift 5.10':
61-
image: swift:5.10-noble
62-
': Swift 6.0':
63-
image: swift:6.0-noble
64-
': Swift 6.1':
65-
image: swift:6.1-noble
66-
container: $[ variables['image'] ]
67-
steps:
68-
- template: .azure/templates/run-make.yml
69-
parameters:
70-
rule: spm_build_plugins
71-
7228
- job: Jazzy
7329
pool:
7430
vmImage: 'macOS-14'

0 commit comments

Comments
 (0)