-
-
Notifications
You must be signed in to change notification settings - Fork 53
126 lines (95 loc) · 4.13 KB
/
nuitka-compile.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
name: 'Compile the monitoring-plugins for Windows using Nuitka'
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches:
- 'main'
tags:
- '*'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch: # yamllint disable-line rule:empty-values
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build-windows-get-list:
runs-on: 'ubuntu-latest'
outputs:
monitoring_plugin_list_json: '${{ steps.save-json.outputs.monitoring_plugin_list_json}}'
steps:
- name: 'checkout the monitoring-plugins repo'
uses: 'actions/checkout@v3'
- name: 'create list of windows checks'
run: |
for dir in check-plugins/*; do
check=$(basename $dir)
if [ -e $dir/.windows ]; then
echo $check >> /tmp/windows-checks
echo "'$check'," >> /tmp/windows-checks-ps-list
fi
done
- name: 'save the list as json'
id: 'save-json'
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "monitoring_plugin_list_json<<$EOF" >> "$GITHUB_OUTPUT"
cat /tmp/windows-checks | jq -R -s -c 'split("\n")[:-1]' >> "$GITHUB_OUTPUT"
echo "$EOF" >> "$GITHUB_OUTPUT"
build-windows:
runs-on: 'windows-latest'
needs: 'build-windows-get-list'
strategy:
matrix:
check: '${{ fromJson(needs.build-windows-get-list.outputs.monitoring_plugin_list_json) }}'
steps:
- name: 'checkout the monitoring-plugins repo'
uses: 'actions/checkout@v3'
with:
# Relative path under $GITHUB_WORKSPACE to place the repository
path: 'monitoring-plugins'
- name: 'checkout the lib repo'
uses: 'actions/checkout@v3'
with:
repository: 'Linuxfabrik/lib'
path: 'lib'
- name: 'install python3.10'
uses: 'actions/setup-python@v3'
with:
python-version: '3.10' # update as soon as nuitka supports latest python
- run: 'python.exe -m pip install --upgrade pip wheel setuptools'
# ordered-set is for nuitka: "Nuitka:WARNING: Using very slow fallback for ordered sets, please install 'ordered-set' or 'orderedset' PyPI packages for best Python compile time performance."
- run: 'pip install --upgrade ordered-set Nuitka Nuitka'
# install 3rd party libraries for all check plugins
- run: 'pip install --requirement ${{ github.workspace }}\monitoring-plugins\requirements.txt'
# info in case of errors
- run: 'pip list'
- run: 'python -m nuitka --assume-yes-for-downloads --mingw64 --follow-imports --include-plugin-directory="${{ github.workspace }}\lib" --output-dir=C:\nuitka-compile-temp --remove-output --standalone ${{ github.workspace }}\monitoring-plugins\check-plugins\${{ matrix.check }}\${{ matrix.check}}'
- name: 'Upload build output as artifact for later zipping'
uses: 'actions/upload-artifact@v3'
with:
name: 'nuitka-build-output-${{ matrix.check }}'
path: 'C:\nuitka-compile-temp\${{ matrix.check }}*'
zip-windows:
# we need to use windows here too, to be able to restore the cache (see https://github.com/marketplace/actions/cache#cache-version)
runs-on: 'windows-latest'
needs: 'build-windows'
steps:
- name: 'download all artifacts'
uses: 'actions/download-artifact@v3'
with:
path: 'C:\artifacts'
- name: 'prepare plugins for zipping'
shell: 'bash'
run: |
cd /c/artifacts
mkdir /c/output
for dir in */*/; do
echo "dir: $dir"
echo cp -rv $dir* /c/output/
cp -rv $dir* /c/output/
done
- name: 'upload the output as monitoring-plugins'
uses: 'actions/upload-artifact@v3'
with:
name: 'monitoring-plugins'
path: 'C:\output\'