Skip to content

Commit e10764c

Browse files
Reuse build and test workflows
1 parent b90d1dd commit e10764c

File tree

3 files changed

+242
-187
lines changed

3 files changed

+242
-187
lines changed
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
name: Reusable Build & E2E Test Matrix
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
description: Version suffix to apply before building
8+
required: false
9+
type: string
10+
default: ""
11+
build-command:
12+
description: npm script to execute (publish/package)
13+
required: true
14+
type: string
15+
secrets:
16+
APPLE_CERTIFICATE_P12:
17+
required: false
18+
CERTIFICATE_PASSWORD:
19+
required: false
20+
APPLE_API_KEY:
21+
required: false
22+
APPLE_API_KEY_ID:
23+
required: false
24+
APPLE_API_ISSUER:
25+
required: false
26+
SENTRY_DSN:
27+
required: false
28+
SENTRY_AUTH_TOKEN:
29+
required: false
30+
TRUSTED_SIGNING_ACCOUNT:
31+
required: false
32+
TRUSTED_SIGNING_ENDPOINT:
33+
required: false
34+
TRUSTED_SIGNING_PROFILE:
35+
required: false
36+
37+
permissions: {}
38+
39+
jobs:
40+
build-test:
41+
name: Build & test (${{ inputs.build-command }})
42+
environment: azure-trusted-signing
43+
permissions:
44+
contents: write
45+
id-token: write
46+
runs-on: ${{ matrix.platform }}
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
include:
51+
- platform: macos-latest
52+
app-path: "out/k6 Studio-darwin-arm64/k6 Studio.app/Contents/MacOS/k6-studio"
53+
- platform: macos-13
54+
app-path: "out/k6 Studio-darwin-x64/k6 Studio.app/Contents/MacOS/k6-studio"
55+
- platform: windows-latest
56+
app-path: "out\\k6 Studio-win32-x64\\k6-studio.exe"
57+
- platform: ubuntu-latest
58+
app-path: "out/k6 Studio-linux-x64/k6-studio"
59+
env:
60+
BUILD_COMMAND: ${{ inputs.build-command }}
61+
steps:
62+
- uses: actions/checkout@v4
63+
with:
64+
persist-credentials: false
65+
66+
- name: Setup Node.js
67+
uses: actions/setup-node@v4
68+
with:
69+
node-version: 22
70+
71+
- name: Install Python 3.11.4
72+
uses: actions/setup-python@v4
73+
with:
74+
python-version: '3.11.4'
75+
76+
- name: Install dependencies
77+
run: npm ci
78+
79+
- name: Setup macOS keychain
80+
if: matrix.platform == 'macos-latest' || matrix.platform == 'macos-13'
81+
run: |
82+
echo "${{ secrets.APPLE_API_KEY }}" > ./apple_api_key.p8
83+
echo ${{ secrets.APPLE_CERTIFICATE_P12 }} | base64 --decode > certificate.p12
84+
security create-keychain -p "${{ secrets.CERTIFICATE_PASSWORD }}" build.keychain
85+
security default-keychain -s build.keychain
86+
security unlock-keychain -p "${{ secrets.CERTIFICATE_PASSWORD }}" build.keychain
87+
security import certificate.p12 -k build.keychain -P "${{ secrets.CERTIFICATE_PASSWORD }}" -T /usr/bin/codesign
88+
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "${{ secrets.CERTIFICATE_PASSWORD }}" build.keychain
89+
90+
- name: Setup .NET SDK
91+
uses: actions/setup-dotnet@v5
92+
if: startsWith(matrix.platform, 'windows-')
93+
with:
94+
dotnet-version: '8.0.414'
95+
96+
- name: Get azure secrets
97+
id: get-azure-secrets
98+
uses: grafana/shared-workflows/actions/get-vault-secrets@5d7e361bc7e0a183cde8afe9899fb7b596d2659b # v1.2.0
99+
if: startsWith(matrix.platform, 'windows-')
100+
with:
101+
export_env: false
102+
repo_secrets: |
103+
client-id=azure-trusted-signing:client-id
104+
subscription-id=azure-trusted-signing:subscription-id
105+
tenant-id=azure-trusted-signing:tenant-id
106+
107+
- name: Azure log in
108+
uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0
109+
if: startsWith(matrix.platform, 'windows-')
110+
with:
111+
client-id: ${{ fromJSON(steps.get-azure-secrets.outputs.secrets).client-id }}
112+
subscription-id: ${{ fromJSON(steps.get-azure-secrets.outputs.secrets).subscription-id }}
113+
tenant-id: ${{ fromJSON(steps.get-azure-secrets.outputs.secrets).tenant-id }}
114+
115+
- name: Install Sign CLI tool
116+
id: install-sign-tool
117+
if: startsWith(matrix.platform, 'windows-')
118+
shell: pwsh
119+
env:
120+
DOTNET_SIGN_VERSION: "0.9.1-beta.25379.1"
121+
run: |
122+
$toolPath = Join-Path -Path ${env:RUNNER_TEMP} -ChildPath (New-Guid).ToString()
123+
New-Item -ItemType Directory -Path $toolPath | Out-Null
124+
125+
dotnet tool install --tool-path $toolPath sign --version ${env:DOTNET_SIGN_VERSION}
126+
127+
if ($LASTEXITCODE -ne 0) {
128+
Write-Output "::error::Failed to install Sign CLI tool"
129+
exit 1
130+
}
131+
132+
"sign-tool=$toolPath" >> ${env:GITHUB_OUTPUT}
133+
134+
- name: Set version for test release
135+
if: inputs.version != ''
136+
env:
137+
PACKAGE_VERSION: ${{ inputs.version }}
138+
run: python update_version.py
139+
140+
- name: Build macOS arm64
141+
if: matrix.platform == 'macos-latest'
142+
env:
143+
NODE_OPTIONS: '--max_old_space_size=8192'
144+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
145+
APPLE_API_KEY: ./apple_api_key.p8
146+
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
147+
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
148+
run: npm run ${BUILD_COMMAND}
149+
150+
- name: Build macOS x86_64
151+
if: matrix.platform == 'macos-13'
152+
env:
153+
NODE_OPTIONS: '--max_old_space_size=8192'
154+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
155+
APPLE_API_KEY: ./apple_api_key.p8
156+
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
157+
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
158+
run: npm run ${BUILD_COMMAND} -- --arch=x64
159+
160+
- name: Build Windows
161+
if: matrix.platform == 'windows-latest'
162+
env:
163+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
164+
TRUSTED_SIGNING_ACCOUNT: ${{ secrets.TRUSTED_SIGNING_ACCOUNT }}
165+
TRUSTED_SIGNING_ENDPOINT: ${{ secrets.TRUSTED_SIGNING_ENDPOINT }}
166+
TRUSTED_SIGNING_PROFILE: ${{ secrets.TRUSTED_SIGNING_PROFILE }}
167+
SIGNTOOL_PATH: ${{ steps.install-sign-tool.outputs.sign-tool }}\sign
168+
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
169+
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
170+
run: npm run ${BUILD_COMMAND}
171+
172+
- name: Build Linux
173+
if: matrix.platform == 'ubuntu-latest'
174+
env:
175+
NODE_OPTIONS: '--max_old_space_size=8192'
176+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
177+
SENTRY_ORG: ${{ vars.SENTRY_ORG }}
178+
SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }}
179+
run: |
180+
sudo apt install -y rpm
181+
182+
# There is a bug on Ubuntu 22.04 regarding stripping a binary for a different architecture.
183+
# https://github.com/electron/forge/issues/3102
184+
# https://github.com/electron/forge/issues/3701
185+
echo "%__strip /bin/true" >> ~/.rpmmacros
186+
187+
npm run ${BUILD_COMMAND}
188+
npm run ${BUILD_COMMAND} -- --arch=arm64
189+
190+
- name: Cleanup macOS certificates
191+
if: matrix.platform == 'macos-latest' || matrix.platform == 'macos-13'
192+
run: |
193+
rm apple_api_key.p8
194+
rm certificate.p12
195+
196+
- name: E2E tests
197+
run: |
198+
echo "Running tests for platform: ${{ matrix.platform }}"
199+
echo "Using app path: ${{ matrix.app-path }}"
200+
npm run wdio -- --app-path="${{ github.workspace }}/${{ matrix.app-path }}"
201+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Release Please E2E Tests
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
permissions: {}
9+
10+
jobs:
11+
e2e-tests:
12+
if: startsWith(github.head_ref, 'release-please--')
13+
uses: ./.github/workflows/e2e-build-test.yml
14+
with:
15+
build-command: package
16+
secrets:
17+
APPLE_CERTIFICATE_P12: ${{ secrets.APPLE_CERTIFICATE_P12 }}
18+
CERTIFICATE_PASSWORD: ${{ secrets.CERTIFICATE_PASSWORD }}
19+
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
20+
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY_ID }}
21+
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
22+
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
23+
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
24+
TRUSTED_SIGNING_ACCOUNT: grafana-premium-eastus
25+
TRUSTED_SIGNING_ENDPOINT: https://eus.codesigning.azure.net/
26+
TRUSTED_SIGNING_PROFILE: grafana-production

0 commit comments

Comments
 (0)