-
Notifications
You must be signed in to change notification settings - Fork 3
142 lines (125 loc) · 4.22 KB
/
build.yml
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# SPDX-FileCopyrightText: © Vegard IT GmbH (https://vegardit.com) and contributors
# SPDX-FileContributor: Sebastian Thomschke, Vegard IT GmbH
# SPDX-License-Identifier: Apache-2.0
#
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions
name: Build
on:
push:
branches:
- '**'
tags-ignore:
- '**'
paths-ignore:
- '**/*.md'
- '.github/*.yml'
- '.semaphore/**/*'
pull_request:
workflow_dispatch:
# https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
inputs:
debug-with-ssh:
description: "Start an SSH session for debugging purposes after tests ran:"
default: never
type: choice
options: [ always, on_failure, on_failure_or_cancelled, never ]
debug-with-ssh-only-for-actor:
description: "Limit access to the SSH session to the GitHub user that triggered the job."
default: true
type: boolean
debug-with-ssh-only-jobs-matching:
description: "Only start an SSH session for jobs matching this regex pattern:"
default: ".*"
type: string
defaults:
run:
shell: bash
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- ubuntu-22.04
- ubuntu-20.04
- windows-latest
steps:
- name: Git Checkout
uses: actions/checkout@v3 #https://github.com/actions/checkout
- name: "Linux: Configure APT"
uses: ./
with:
repo-name: ${{ github.repository }}
repo-branch: ${{ github.ref_name }}
- name: Run shellcheck
run: bash tests/run-shellcheck.sh
- name: Install bashcov
if: ${{ runner.os == 'Linux' && !env.ACT }}
run: |
ruby --version
echo "gem $(gem --version)"
if [[ "${{ matrix.os}}" == "ubuntu-20.04" ]]; then
# workaround for bashcov error:
# The last version of bashcov (>= 0) to support your Ruby & RubyGems was 1.8.2.
# Try installing it with `gem install bashcov -v 1.8.2`"
sudo gem install bashcov -v 1.8.2
else
sudo gem install bashcov
fi
sudo gem install simplecov-console
- name: Run tests
timeout-minutes: 5
run: |
set -eu
if [[ "${{ runner.os }}" == "Linux" && "${{ env.ACT }}" != "true" ]]; then
bashcov --skip-uncovered tests/run-tests.sh
else
bash tests/run-tests.sh
fi
- name: "SSH session for debugging: check"
id: debug_ssh_sesssion_check
if: always()
run: |
set -eu
job_filter_pattern="${{ inputs.debug-with-ssh-only-jobs-matching }}"
echo "job_filter: $job_filter_pattern"
job_info=$(echo "$GITHUB_JOB ${{ toJSON(matrix) }}" | tr -d '\n')
echo "job_info: $job_info"
if [[ "$job_info" =~ .*$job_filter_pattern.* ]] && case "${{ job.status }}" in
success) [[ "${{ inputs.debug-with-ssh }}" == always ]] ;;
cancelled) [[ "${{ inputs.debug-with-ssh }}" == on_failure_or_cancelled ]] ;;
failure) [[ "${{ inputs.debug-with-ssh }}" =~ on_failure.* ]] ;;
esac; then
echo "start_session=true" >>$GITHUB_OUTPUT;
fi
- name: "SSH session for debugging: start"
uses: mxschmitt/action-tmate@v3 # https://github.com/mxschmitt/action-tmate
if: always() && steps.debug_ssh_sesssion_check.outputs.start_session
with:
limit-access-to-actor: ${{ inputs.debug-with-ssh-only-for-actor }}
test-containers:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
image:
- debian:unstable-slim
- debian:testing-slim
- debian:stable-slim
- debian:bookworm-slim
- debian:buster-slim
- debian:bullseye-slim
- ubuntu:devel
- ubuntu:latest
- ubuntu:22.04
- ubuntu:20.04
- ubuntu:18.04
- ubuntu:16.04
steps:
- name: Git Checkout
uses: actions/checkout@v3 #https://github.com/actions/checkout
- name: Run tests in [${{ matrix.image }}]
timeout-minutes: 5
run: bash tests/run-tests-in-docker.sh ${{ matrix.image }}