Skip to content

Commit eb02c38

Browse files
committed
ci: added dry-run testing action
1 parent c3335fd commit eb02c38

File tree

3 files changed

+61
-5
lines changed

3 files changed

+61
-5
lines changed

.github/workflows/main.yml

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,51 @@ jobs:
170170
- name: Verify Swift version
171171
run: swift --version | grep ${{ steps.setup-swift.outputs.swift-version }} || exit 1
172172

173+
dry-run:
174+
name: Check action with dry run
175+
if: needs.ci.outputs.run == 'true'
176+
needs: ci
177+
runs-on: ubuntu-latest
178+
concurrency:
179+
group: dry-run-${{ github.ref }}
180+
cancel-in-progress: true
181+
182+
steps:
183+
- name: Checkout repository
184+
uses: actions/checkout@v3
185+
186+
- name: Setup Node.js
187+
id: setup-node
188+
uses: actions/setup-node@v3
189+
with:
190+
cache: npm
191+
192+
- name: Cache dependencies
193+
id: cache-node
194+
uses: actions/[email protected]
195+
with:
196+
key: node-${{ github.ref }}
197+
path: node_modules
198+
199+
- name: Setup npm pacakges
200+
run: npm install
201+
202+
- name: Build
203+
run: npm run build && npm run package
204+
205+
- name: Run
206+
id: setup-swift
207+
uses: ./
208+
with:
209+
check-latest: ${{ github.event_name == 'schedule' }}
210+
dry-run: true
211+
212+
- name: Verify Swift version
213+
uses: addnab/docker-run-action@v3
214+
with:
215+
image: swift:${{ fromJSON(steps.setup-swift.outputs.toolchain).docker }}
216+
run: swift --version | grep ${{ steps.setup-swift.outputs.swift-version }} || exit 1
217+
173218
dependabot:
174219
name: Check dependabot PR raised updating swiftorg
175220
if: needs.ci.outputs.run == 'true' && github.event_name == 'pull_request' && github.actor == 'dependabot[bot]'
@@ -316,7 +361,7 @@ jobs:
316361
merge:
317362
name: Auto-merge submodule update PR
318363
if: needs.ci.outputs.run == 'true' && needs.dependabot.outputs.merge == 'true'
319-
needs: [ci, analyze, unit-test, integration-test, dependabot, feature-test]
364+
needs: [ci, analyze, unit-test, integration-test, dry-run, dependabot, feature-test]
320365
runs-on: ubuntu-latest
321366
concurrency:
322367
group: swiftorg-update
@@ -334,7 +379,7 @@ jobs:
334379
cd:
335380
name: Create release
336381
if: always() && needs.ci.outputs.run == 'true' && needs.ci.outputs.release == 'true' && (needs.analyze.result == 'success' || needs.analyze.result == 'skipped')
337-
needs: [ci, analyze, unit-test, integration-test, feature-test]
382+
needs: [ci, analyze, unit-test, integration-test, dry-run, feature-test]
338383
runs-on: ubuntu-latest
339384
concurrency:
340385
group: cd-${{ github.ref }}

dist/index.js

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ async function run() {
1616
await submodule.update()
1717
core.endGroup()
1818

19-
const dryRun = core.getBooleanInput('development')
19+
const dryRun = core.getBooleanInput('dry-run')
2020
let snapshot: ToolchainSnapshot
2121
let installedVersion: string
2222
if (dryRun) {
@@ -26,7 +26,12 @@ async function run() {
2626
} else {
2727
throw new Error(`No Swift toolchain found for ${version}`)
2828
}
29-
installedVersion = requestedVersion
29+
const match = /swift-(.*)-/.exec(toolchain.branch)
30+
if (match && match.length > 1) {
31+
installedVersion = match[1]
32+
} else {
33+
installedVersion = requestedVersion
34+
}
3035
} else {
3136
const installer = await Platform.install(version)
3237
snapshot = installer.data

0 commit comments

Comments
 (0)