-
Notifications
You must be signed in to change notification settings - Fork 52
125 lines (109 loc) · 4.33 KB
/
Copy pathci.yml
File metadata and controls
125 lines (109 loc) · 4.33 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: CI
on:
push:
branches: [master]
tags: [v*]
pull_request:
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.10' # Replace this with the minimum Julia version that your package supports. E.g. if your package requires Julia 1.5 or higher, change this to '1.5'.
#- '1.3' # Leave this line unchanged. '1' will automatically expand to the latest stable 1.x release of Julia.
# - 'nightly'
os:
- self-hosted
- ubuntu-latest
- macos-15-intel # for fun and knowledge
# - ubuntu-latest
# arch:
# - x64
steps:
- name: Fix PATH (macOS)
# necessary to find gpg for coverage step
# Homebrew is located differently on macOSX/Intel and macOS/ARM
if: runner.os == 'macOS'
run: |
if [ "${{ runner.arch }}" = "ARM64" ]; then
echo "/opt/homebrew/bin:/opt/homebrew/sbin" >> $GITHUB_PATH
else
echo "/usr/local/bin" >> $GITHUB_PATH
fi
- name: Checkout repository
uses: actions/checkout@v6
- name: Setup julia
uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
# arch: ${{ matrix.arch }} \todo required?
- name: Cache Julia packages (GitHub-hosted runners)
if: contains(matrix.os, 'ubuntu') || contains(matrix.os, 'windows') || contains(matrix.os, 'macOs')
uses: julia-actions/cache@v3
- name: Cache Julia artifacts (self-hosted runners)
if: contains(matrix.os, 'self-hosted')
uses: actions/cache@v5
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- name: Cache Julia compiled code (self-hosted runners)
if: contains(matrix.os, 'self-hosted')
uses: actions/cache@v5
with:
path: ~/.julia/compiled
key: ${{ runner.os }}-julia-compiled-${{ matrix.version }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-julia-compiled-${{ matrix.version }}-
- name: Build julia package
uses: julia-actions/julia-buildpkg@v1
- name: Run tests
env:
JULIA_NUM_THREADS: auto
PR_LABELS: ${{ toJSON(github.event.pull_request.labels) }}
run: |
julia --math-mode=ieee --color=yes --project=@. -e '
import Pkg
# Parse labels from the environment variable using Regex to avoid JSON dependency
labels_json = get(ENV, "PR_LABELS", "[]")
# Regex to match "name": "value" pattern in the JSON string
# Handles escaped quotes if necessary, though simple labels rarely have them
name_pattern = r"\"name\"\s*:\s*\"((?:\\.|[^\"\\])*)\""
# Extract test names from labels with the specific prefix
prefix = "Run test(s): "
test_args = String[]
for m in eachmatch(name_pattern, labels_json)
name = m.captures[1]
if startswith(name, prefix)
# Remove prefix and split by space, comma, or pipe
arg_str = strip(replace(name, prefix => ""))
for arg in split(arg_str, r"[\s,|]+"; keepempty=false)
push!(test_args, arg)
end
end
end
# Log what we are doing
if isempty(test_args)
println("No specific test labels found. Running all tests.")
else
println("Detected labels for specific tests. Running: ", join(test_args, ", "))
end
# Run tests
Pkg.test(coverage=true, test_args=test_args)
'
- name: Compute coverage
uses: julia-actions/julia-processcoverage@v1
- name: Process coverage
uses: codecov/codecov-action@v6
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
files: lcov.info