forked from ontoportal/ncbo_cron
-
Notifications
You must be signed in to change notification settings - Fork 6
87 lines (75 loc) · 2.4 KB
/
Copy pathtestkit-unit-tests.yml
File metadata and controls
87 lines (75 loc) · 2.4 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
name: Docker Unit Tests
on:
push:
branches:
- '**'
tags-ignore:
- '**'
pull_request:
env:
# CI execution mode for backend tests:
# - container: run `test:docker:<backend>:container` (default)
# - native: run `test:docker:<backend>` on host Ruby
OPTK_CI_RUN_MODE: ${{ vars.OPTK_CI_RUN_MODE || 'container' }}
# Example override to force native mode in this workflow file:
# OPTK_CI_RUN_MODE: native
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
backends: ${{ steps.cfg.outputs.backends }}
steps:
- uses: actions/checkout@v6
- id: cfg
name: Read backend matrix from .ontoportal-testkit.yml
run: |
BACKENDS=$(ruby -ryaml -rjson -e 'c=YAML.safe_load_file(".ontoportal-testkit.yml") || {}; b=c["backends"] || %w[fs ag vo gd]; puts JSON.generate(b)')
echo "backends=$BACKENDS" >> "$GITHUB_OUTPUT"
test:
needs: prepare
runs-on: ubuntu-latest
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
backend: ${{ fromJson(needs.prepare.outputs.backends) }}
steps:
- uses: actions/checkout@v6
- name: Set up Ruby from .ruby-version
uses: ruby/setup-ruby@v1
with:
ruby-version: .ruby-version
bundler-cache: true
- name: Set up Java 11 (native mode)
if: env.OPTK_CI_RUN_MODE == 'native'
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '11'
- name: Install native system dependencies
if: env.OPTK_CI_RUN_MODE == 'native'
run: |
sudo apt-get update
sudo apt-get install -y raptor2-utils
- name: Run unit tests
env:
CI: "true"
TESTOPTS: "--verbose"
BACKEND: ${{ matrix.backend }}
run: |
MODE="${OPTK_CI_RUN_MODE:-container}"
TASK="test:docker:${BACKEND}"
if [ "$MODE" = "container" ]; then
TASK="${TASK}:container"
elif [ "$MODE" != "native" ]; then
echo "Invalid OPTK_CI_RUN_MODE=$MODE (expected container or native)"
exit 1
fi
bundle exec rake "$TASK"
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: unittests,${{ matrix.backend }}
verbose: true
fail_ci_if_error: false