Skip to content

Commit b8cd9f7

Browse files
Wei SunWei Sun
authored andcommitted
Extract common steps into GitHub action template
1 parent a0e8099 commit b8cd9f7

File tree

3 files changed

+77
-38
lines changed

3 files changed

+77
-38
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: Test & Coverage
3+
description: Run tests, optionally gather coverage data and run danger
4+
inputs:
5+
include-coverage:
6+
description: Option to include a danger-swift coverage step
7+
required: false
8+
default: "false"
9+
danger-token:
10+
description: Option to include a token for danger related step
11+
required: false
12+
default: ""
13+
14+
runs:
15+
using: composite
16+
17+
steps:
18+
- name: Run Tests
19+
run: |
20+
if [ ${{ inputs.include-coverage }} = true ]; then
21+
npm install -g danger
22+
swift test --enable-code-coverage
23+
swift run danger-swift ci \
24+
-c release \
25+
--dangerfile DangerfileCoverage.swift \
26+
--id "Coverage"
27+
else
28+
swift test
29+
fi
30+
shell: bash
31+
env:
32+
DANGER_GITHUB_API_TOKEN: ${{ inputs.danger-token }}

.github/workflows/gha_pull_request.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

.github/workflows/gha_verify.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
name: Verify
3+
4+
on:
5+
pull_request:
6+
branches:
7+
- master
8+
push:
9+
branches:
10+
- master
11+
12+
jobs:
13+
danger:
14+
runs-on: ubuntu-latest
15+
name: "🚫 Run Danger"
16+
steps:
17+
- uses: actions/checkout@v2
18+
- run: npm install -g danger
19+
- run: swift run danger-swift ci -c release --id "Lint"
20+
env:
21+
DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_SWIFT_GITHUB_TOKEN }}
22+
23+
linux:
24+
runs-on: ubuntu-latest
25+
name: 🐧 Linux Test & Verify
26+
steps:
27+
- uses: actions/checkout@v2
28+
- name: Test
29+
uses: ./.github/actions/test-verify-action
30+
with:
31+
include-coverage: false
32+
33+
macos:
34+
runs-on: macos-11
35+
name:  MacOS Test & Verify
36+
steps:
37+
- uses: actions/checkout@v2
38+
- name: Test & Coverage
39+
uses: ./.github/actions/test-verify-action
40+
with:
41+
include-coverage: true
42+
danger-token: ${{ secrets.DANGER_SWIFT_GITHUB_TOKEN }}
43+
44+
env:
45+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)