Skip to content

Commit 8bf8022

Browse files
committed
ci: added dry-run testing action
1 parent f865eff commit 8bf8022

File tree

3 files changed

+62
-6
lines changed

3 files changed

+62
-6
lines changed

.github/workflows/main.yml

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

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

dist/index.js

Lines changed: 8 additions & 2 deletions
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)