Skip to content

Commit 1d46ea0

Browse files
committed
WIP: ci: try build on alpine
1 parent 6fbf768 commit 1d46ea0

File tree

2 files changed

+54
-12
lines changed

2 files changed

+54
-12
lines changed

.github/actions/environment/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ runs:
1919

2020
# Needed for Android SDK setup step
2121
- uses: actions/setup-java@v3
22+
if: ${{ !matrix.runner.container }}
2223
with:
2324
distribution: 'temurin'
2425
java-version: '17'
2526

2627
- name: Setup Android SDK
28+
if: ${{ !matrix.runner.container }}
2729
uses: android-actions/setup-android@07976c6290703d34c16d382cb36445f98bb43b1f # v3.2.0
2830
with:
2931
log-accepted-android-sdk-licenses: false
@@ -41,6 +43,7 @@ runs:
4143
cd -
4244
4345
- name: Set Java Version
46+
if: ${{ !matrix.runner.container }}
4447
uses: actions/setup-java@v3
4548
with:
4649
distribution: 'temurin'

.github/workflows/build.yml

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,29 @@ on:
1111

1212
jobs:
1313
build-sentry-native:
14-
name: sentry-native (${{ matrix.os }})
15-
runs-on: ${{ matrix.os }}
14+
name: sentry-native (${{ matrix.runner.container || matrix.runner.os }})
15+
runs-on: ${{ matrix.runner.os }}
16+
container: ${{ matrix.runner.container }}
1617
strategy:
1718
fail-fast: false
1819
matrix:
1920
# Pin ubuntu to ensure mono is installed
2021
# Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703
21-
os: [ubuntu-22.04, windows-latest, macos-15]
22+
runner: [
23+
{os: ubuntu-22.04},
24+
{os: ubuntu-latest, container: alpine:3.21, target: Linux-musl},
25+
{os: windows-latest},
26+
{os: macos-15}
27+
]
2228

2329
steps:
30+
- name: Install build dependencies for Alpine Linux
31+
if: ${{ startsWith(matrix.runner.container, 'alpine') }}
32+
run: |
33+
apk update
34+
apk add bash build-base cmake curl-dev git powershell sudo tar wget
35+
git config --global --add safe.directory $GITHUB_WORKSPACE
36+
2437
- name: Checkout
2538
uses: actions/checkout@v4
2639

@@ -30,14 +43,15 @@ jobs:
3043
id: cache
3144
with:
3245
path: src/Sentry/Platforms/Native/sentry-native
33-
key: sentry-native-${{ runner.os }}-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
46+
key: sentry-native-${{ matrix.runner.target || runner.os }}-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
3447
enableCrossOsArchive: true
3548

3649
- name: Remove unused applications
50+
if: ${{ !matrix.runner.container }}
3751
uses: ./.github/actions/freediskspace
3852

3953
- name: Install build dependencies
40-
if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'Linux'
54+
if: steps.cache.outputs.cache-hit != 'true' && runner.os == 'Linux' && !matrix.runner.container
4155
run: |
4256
sudo apt update
4357
sudo apt install libcurl4-openssl-dev
@@ -48,28 +62,44 @@ jobs:
4862

4963
build:
5064
needs: build-sentry-native
51-
name: .NET (${{ matrix.os }})
52-
runs-on: ${{ matrix.os }}
65+
name: .NET (${{ matrix.runner.container || matrix.runner.os }})
66+
runs-on: ${{ matrix.runner.os }}
67+
container: ${{ matrix.runner.container }}
5368

5469
strategy:
5570
fail-fast: false
5671
matrix:
5772
# Pin ubuntu to ensure mono is installed
5873
# Pin macos to get the version of Xcode that we need: https://github.com/actions/runner-images/issues/10703
59-
os: [ubuntu-22.04, windows-latest, macos-15]
74+
runner: [
75+
{os: ubuntu-22.04},
76+
{os: ubuntu-latest, container: alpine:3.21, target: Linux-musl},
77+
{os: windows-latest},
78+
{os: macos-15}
79+
]
6080

6181
steps:
6282
- name: Cancel Previous Runs
6383
if: github.ref_name != 'main' && !startsWith(github.ref_name, 'release/')
6484
uses: styfle/cancel-workflow-action@85880fa0301c86cca9da44039ee3bb12d3bedbfa # Tag: 0.12.1
6585

86+
- name: Install build dependencies for Alpine Linux
87+
if: ${{ startsWith(matrix.runner.container, 'alpine') }}
88+
run: |
89+
apk update
90+
apk add bash build-base cmake curl-dev git grpc-plugins icu openjdk11 powershell sudo tar wget
91+
git config --global --add safe.directory $GITHUB_WORKSPACE
92+
echo "PROTOBUF_PROTOC=/usr/bin/protoc" >> $GITHUB_ENV
93+
echo "GRPC_PROTOC_PLUGIN=/usr/bin/grpc_csharp_plugin" >> $GITHUB_ENV
94+
6695
- name: Checkout
6796
uses: actions/checkout@v4
6897
with:
6998
submodules: recursive
7099
fetch-depth: 2 # default is 1 and codecov needs > 1
71100

72101
- name: Remove unused applications
102+
if: ${{ !matrix.runner.container }}
73103
uses: ./.github/actions/freediskspace
74104

75105
# We use macOS for the final publishing build so we get all the iOS/macCatalyst targets in the packages
@@ -78,13 +108,21 @@ jobs:
78108
run: echo "CI_PUBLISHING_BUILD=true" >> $GITHUB_ENV
79109

80110
- name: Download sentry-native (Linux)
81-
if: ${{ (env.CI_PUBLISHING_BUILD == 'true') || (runner.os == 'Linux') }}
111+
if: ${{ (env.CI_PUBLISHING_BUILD == 'true') || (runner.os == 'Linux' && !matrix.runner.container) }}
82112
uses: actions/cache/restore@v4
83113
with:
84114
path: src/Sentry/Platforms/Native/sentry-native
85115
key: sentry-native-Linux-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
86116
fail-on-cache-miss: true
87117

118+
- name: Download sentry-native (Linux musl)
119+
if: ${{ (env.CI_PUBLISHING_BUILD == 'true') || (startsWith(matrix.runner.container, 'alpine')) }}
120+
uses: actions/cache/restore@v4
121+
with:
122+
path: src/Sentry/Platforms/Native/sentry-native
123+
key: sentry-native-Linux-musl-${{ hashFiles('scripts/build-sentry-native.ps1') }}-${{ hashFiles('.git/modules/modules/sentry-native/HEAD') }}
124+
fail-on-cache-miss: true
125+
88126
- name: Download sentry-native (macOS)
89127
if: ${{ (env.CI_PUBLISHING_BUILD == 'true') || (runner.os == 'macOS') }}
90128
uses: actions/cache/restore@v4
@@ -106,14 +144,15 @@ jobs:
106144
uses: ./.github/actions/environment
107145

108146
- name: Build Native Dependencies
147+
if: ${{ ! matrix.runner.container }}
109148
uses: ./.github/actions/buildnative
110149

111150
- name: Restore .NET Dependencies
112-
run: dotnet restore Sentry-CI-Build-${{ runner.os }}.slnf --nologo
151+
run: dotnet restore Sentry-CI-Build-${{ matrix.runner.target || runner.os }}.slnf --nologo
113152

114153
- name: Build
115154
id: build
116-
run: dotnet build Sentry-CI-Build-${{ runner.os }}.slnf -c Release --no-restore --nologo -v:minimal -flp:logfile=build.log -p:CopyLocalLockFileAssemblies=true -bl:build.binlog
155+
run: dotnet build Sentry-CI-Build-${{ matrix.runner.target || runner.os }}.slnf -c Release --no-restore --nologo -v:minimal -flp:logfile=build.log -p:CopyLocalLockFileAssemblies=true -bl:build.binlog
117156

118157
- name: Upload build logs
119158
if: ${{ steps.build.outcome != 'skipped' }}
@@ -123,7 +162,7 @@ jobs:
123162
path: build.binlog
124163

125164
- name: Test
126-
run: dotnet test Sentry-CI-Build-${{ runner.os }}.slnf -c Release --no-build --nologo -l GitHubActions -l "trx;LogFilePrefix=testresults_${{ runner.os }}" --collect "XPlat Code Coverage"
165+
run: dotnet test Sentry-CI-Build-${{ matrix.runner.target || runner.os }}.slnf -c Release --no-build --nologo -l GitHubActions -l "trx;LogFilePrefix=testresults_${{ runner.os }}" --collect "XPlat Code Coverage"
127166

128167
- name: Upload code coverage
129168
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d

0 commit comments

Comments
 (0)