Skip to content

Commit 57eda56

Browse files
committed
ci: add initial CI
1 parent 0cd18c5 commit 57eda56

4 files changed

Lines changed: 217 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Environment (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Version [e.g. 22]
29+
- Swift Version [e.g. 5.9]
30+
- Xcode Version [e.g. 15.0]
31+
32+
**Additional context**
33+
Add any other context about the problem here.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: enhancement
6+
assignees: ''
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12+
13+
**Describe the solution you'd like**
14+
A clear and concise description of what you want to happen.
15+
16+
**Describe alternatives you've considered**
17+
A clear and concise description of any alternative solutions or features you've considered.
18+
19+
**Additional context**
20+
Add any other context or screenshots about the feature request here.

.github/workflows/ci.yml

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
env:
10+
SWIFT_VERSION: 5.9
11+
12+
jobs:
13+
test:
14+
name: Test
15+
runs-on: macos-latest
16+
strategy:
17+
matrix:
18+
destination:
19+
- platform=macOS
20+
- platform=iOS Simulator,name=iPhone 15
21+
- platform=watchOS Simulator,name=Apple Watch Series 9 (45mm)
22+
- platform=tvOS Simulator,name=Apple TV 4K (3rd generation)
23+
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v4
27+
28+
- name: Setup Xcode
29+
uses: maxim-lobanov/setup-xcode@v1
30+
with:
31+
xcode-version: latest-stable
32+
33+
- name: Swift Package Manager Cache
34+
uses: actions/cache@v3
35+
with:
36+
path: .build
37+
key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
38+
restore-keys: |
39+
${{ runner.os }}-spm-
40+
41+
- name: Build
42+
run: swift build -v
43+
44+
- name: Run Tests
45+
run: swift test --enable-code-coverage
46+
47+
- name: Generate Code Coverage Report
48+
run: |
49+
xcrun llvm-cov export -format="lcov" \
50+
.build/debug/SwiftNetworkKitPackageTests.xctest/Contents/MacOS/SwiftNetworkKitPackageTests \
51+
-instr-profile .build/debug/codecov/default.profdata > coverage.lcov
52+
53+
- name: Upload Coverage to Codecov
54+
uses: codecov/codecov-action@v3
55+
with:
56+
file: ./coverage.lcov
57+
fail_ci_if_error: false
58+
59+
lint:
60+
name: SwiftLint
61+
runs-on: macos-latest
62+
63+
steps:
64+
- name: Checkout
65+
uses: actions/checkout@v4
66+
67+
- name: SwiftLint
68+
uses: norio-nomura/action-swiftlint@3.2.1
69+
with:
70+
args: --strict
71+
72+
validate-package:
73+
name: Validate Swift Package
74+
runs-on: macos-latest
75+
76+
steps:
77+
- name: Checkout
78+
uses: actions/checkout@v4
79+
80+
- name: Validate Package
81+
run: swift package dump-package
82+
83+
- name: Check Package Dependencies
84+
run: swift package show-dependencies
85+
86+
documentation:
87+
name: Documentation
88+
runs-on: macos-latest
89+
90+
steps:
91+
- name: Checkout
92+
uses: actions/checkout@v4
93+
94+
- name: Setup Xcode
95+
uses: maxim-lobanov/setup-xcode@v1
96+
with:
97+
xcode-version: latest-stable
98+
99+
- name: Build Documentation
100+
run: |
101+
swift package --allow-writing-to-directory docs \
102+
generate-documentation --target SwiftNetworkKit \
103+
--disable-indexing \
104+
--transform-for-static-hosting \
105+
--hosting-base-path SwiftNetworkKit \
106+
--output-path docs
107+
108+
- name: Deploy to GitHub Pages
109+
if: github.ref == 'refs/heads/main'
110+
uses: peaceiris/actions-gh-pages@v3
111+
with:
112+
github_token: ${{ secrets.GITHUB_TOKEN }}
113+
publish_dir: ./docs
114+
115+
release:
116+
name: Release
117+
runs-on: macos-latest
118+
needs: [test, lint, validate-package]
119+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
120+
121+
steps:
122+
- name: Checkout
123+
uses: actions/checkout@v4
124+
with:
125+
fetch-depth: 0
126+
127+
- name: Setup Node.js
128+
uses: actions/setup-node@v3
129+
with:
130+
node-version: '18'
131+
132+
- name: Install semantic-release
133+
run: |
134+
npm install -g semantic-release @semantic-release/changelog @semantic-release/git
135+
136+
- name: Semantic Release
137+
env:
138+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
139+
run: npx semantic-release

.releaserc.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"branches": ["main"],
3+
"plugins": [
4+
"@semantic-release/commit-analyzer",
5+
"@semantic-release/release-notes-generator",
6+
"@semantic-release/changelog",
7+
"@semantic-release/git",
8+
"@semantic-release/github"
9+
],
10+
"preset": "angular",
11+
"releaseRules": [
12+
{"type": "feat", "release": "minor"},
13+
{"type": "fix", "release": "patch"},
14+
{"type": "perf", "release": "patch"},
15+
{"type": "revert", "release": "patch"},
16+
{"type": "docs", "release": "patch"},
17+
{"type": "style", "release": false},
18+
{"type": "refactor", "release": "patch"},
19+
{"type": "test", "release": false},
20+
{"type": "build", "release": false},
21+
{"type": "ci", "release": false},
22+
{"type": "chore", "release": false},
23+
{"breaking": true, "release": "major"}
24+
]
25+
}

0 commit comments

Comments
 (0)