-
-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (77 loc) · 2.63 KB
/
swift-package.yml
File metadata and controls
85 lines (77 loc) · 2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Run Tests with Swift Package
on:
workflow_call:
inputs:
matrix:
description: The strategy-matrix to use containing OS and Swift version
required: true
type: string
tracked-files:
description: The files on which changes tracked and based on change actions are run
required: false
type: string
default: |
Sources/**/*.swift
Tests/**/*
Package*.swift
secrets:
CODECOV_TOKEN:
description: Codecov token to upload code coverage
jobs:
swift-package:
name: Run tests on ${{ matrix.os }} with swift version ${{ matrix.swift }} dependencies ${{ matrix.dependencies != '' && toJSON(matrix.dependencies) }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
matrix: ${{ fromJSON(inputs.matrix) }}
steps:
- name: Check should proceed running steps
id: precondition
uses: SwiftyLab/ci/actions/condition@main
with:
files: ${{ inputs.tracked-files }}
- name: Setup repository
if: steps.precondition.outputs.proceed == 'true'
uses: SwiftyLab/ci/actions/setup@main
with:
swift: ${{ matrix.swift }}
- name: Resolve packages
if: matrix.dependencies != ''
id: resolve_packages
uses: actions/github-script@v8.0.0
env:
PACKAGES: ${{ toJSON(matrix.dependencies) }}
with:
script: |
const { execSync } = require('child_process');
const { PACKAGES } = process.env;
const packages = JSON.parse(PACKAGES);
execSync(`swift package resolve`);
for (const [package, version] of Object.entries(packages)) {
core.startGroup(`Resolving ${package} to ${version}`);
execSync(`swift package resolve ${package} --version ${version}`);
core.endGroup();
}
- name: Run tests
if: steps.precondition.outputs.proceed == 'true'
run: npm run test
- name: Swift Coverage Report
if: |
steps.precondition.outputs.proceed == 'true' &&
(github.event_name == 'push' || github.event_name == 'pull_request')
continue-on-error: true
uses: maxep/spm-lcov-action@0.3.1
with:
file-format: lcov
output-file: ./coverage.lcov
- name: Codecov upload
if: |
steps.precondition.outputs.proceed == 'true' &&
(github.event_name == 'push' || github.event_name == 'pull_request')
continue-on-error: true
uses: codecov/codecov-action@v5.5.2
with:
token: ${{ secrets.CODECOV_TOKEN || vars.CODECOV_TOKEN }}
fail_ci_if_error: true