-
Notifications
You must be signed in to change notification settings - Fork 0
213 lines (185 loc) · 6.79 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# 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:
- '**/*.adoc'
- '**/*.md'
- '.editorconfig'
- '.git*'
- '.github/*.yml'
- 'tools'
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
test-target:
description: "If specified only the given target will be tested"
default: ""
type: choice
options: [ "", cpp, cs, eval, flash, hl, java, jvm, lua, neko, node, php, python ]
defaults:
run:
shell: bash
env:
# these env variables are also used by TestRunner.hx
TEST_SSH_HOST: 127.0.0.1
TEST_SSH_PORT: 2222
TEST_SSH_USER: testuser
TEST_SSH_PW: MySuperPW123
TEST_SSH_PEMKEY_FILE: test/id_key.txt
TEST_SSH_PPKKEY_FILE: test/id_key.ppk
TEST_SSH_PUBKEY_FILE: test/id_pub.txt
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
haxe:
- nightly
- 4.3.2
- 4.2.5
steps:
- name: Show environment variables
run: env | sort
- name: Git Checkout
uses: actions/checkout@v4 #https://github.com/actions/checkout
##################################################
# Install software
##################################################
- name: "Linux: Configure fast APT mirror"
uses: vegardit/fast-apt-mirror.sh@v1
- name: "MacOS: Install docker"
if: runner.os == 'macOS'
uses: douglascamata/setup-docker-macos-action@main
timeout-minutes: 15
- name: "Install: Putty plink"
run: |
set -eu
case "${{runner.os}}" in
macOS) brew install putty; plink -V ;;
Linux) sudo apt-get install -y putty-tools; plink -V ;;
Windows)
mkdir /tmp/kitty
curl -sSfL https://www.9bis.net/kitty/files/klink.exe -o /tmp/kitty/klink.exe
echo "$(cygpath -wa /tmp/kitty)" >> $GITHUB_PATH
/tmp/kitty/klink -V
;;
esac
##################################################
# Run local SSH server
##################################################
- name: "Create Windows testuser for SSH"
if: runner.os == 'Windows'
shell: cmd
run: net user /ADD ${{ env.TEST_SSH_USER }} ${{ env.TEST_SSH_PW }}
- name: "Start local test SSH server"
run: |
set -euxo pipefail
chmod 400 test/id_*
case "${{ runner.os }}" in
Windows)
# prevents setgid: Invalid argument
mkpasswd -l | tee /etc/passwd
mkgroup -l > /etc/group
/usr/bin/ssh-keygen -vA # generate host keys for sshd
cat <<EOF > /etc/ssh/sshd_config
ListenAddress $TEST_SSH_HOST
Port $TEST_SSH_PORT
PermitRootLogin no
StrictModes no
PubkeyAuthentication yes
IgnoreUserKnownHosts yes
PasswordAuthentication yes
PermitEmptyPasswords no
LogLevel DEBUG3
match User $TEST_SSH_USER
AuthorizedKeysFile $(pwd)/$TEST_SSH_PUBKEY_FILE
EOF
/usr/bin/sshd -T # test config
# install PsExec to run sshd as SYSTEM without having to configure it as a system service
curl -sSfL -o PSTools.zip http://download.sysinternals.com/files/PSTools.zip
unzip PSTools.zip PsExec64.exe
# launch sshd in background as SYSTEM to prevent "/usr/bin/bash: Operation not permitted"
./PsExec64 -accepteula -d -s "$(cygpath -w /usr/bin/sshd)" -E /tmp/sshd.log &
sleep 5
# TODO for some reason on GitHub Actions under Windows accepting new host keys doesn't work
# when plink/klink is executed via the PuttySSHClient class, so for now we accept
# the key before the Windows tests run
klink -auto-store-sshkey \
-P $TEST_SSH_PORT \
-pw $TEST_SSH_PW \
$TEST_SSH_USER@$TEST_SSH_HOST \
"whoami"
;;
*)
touch /tmp/sshd.log
docker run -d --rm \
--name "openssh-server" \
-e PASSWORD_ACCESS=true \
-e USER_NAME=$TEST_SSH_USER \
-e USER_PASSWORD=$TEST_SSH_PW \
-e PUBLIC_KEY_FILE=/config/id_pub.txt \
-p $TEST_SSH_PORT:2222 \
--volume $(pwd)/$TEST_SSH_PUBKEY_FILE:/config/id_pub.txt:ro \
--volume /tmp/sshd.log:/config/logs/openssh/current:rw \
lscr.io/linuxserver/openssh-server:latest
;;
esac
##################################################
# Run Haxe Tests
##################################################
- name: Test with Haxe
uses: vegardit/haxe-reusable-workflows/.github/actions/test-with-haxe@v1
with:
haxe-version: ${{ matrix.haxe }}
haxe-libs: haxe-concurrent haxe-doctest haxe-files haxe-strings hx3compat
# Haxe targets to test with, by default all are set to false:
test-cpp: true
test-cs: true
test-hl: true
test-java: true
test-jvm: true
test-neko: true
test-python: true
# provide SSH access to the GitHub runner for manual debugging purposes
debug-with-ssh: ${{ inputs.debug-with-ssh || 'never' }}
debug-with-ssh-only-for-actor: ${{ inputs.debug-with-ssh-only-for-actor || false }}
debug-with-ssh-only-jobs-matching: ${{ inputs.debug-with-ssh-only-jobs-matching }}
##################################################
# Dipslay logs
##################################################
- name: Shutdown SSHD and display logs
if: always()
run: |
case "${{runner.os}}" in
Windows) ;;
*) docker container rm openssh-server --force || true ;;
esac
cat /tmp/sshd.log || true