Skip to content

Commit f879ee6

Browse files
committed
[SEM-526] Add github workflow
1 parent b275d32 commit f879ee6

20 files changed

+187
-151
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Build package on Push or Pull Request
2+
3+
on:
4+
push
5+
6+
jobs:
7+
Prepare:
8+
name: 'Prepare'
9+
uses: Ultimaker/embedded-workflows/.github/workflows/prepare_env.yml@main
10+
with:
11+
BUILD_DOCKER_CACHE: true
12+
secrets: inherit
13+
14+
Shellcheck:
15+
name: 'Test'
16+
needs: Prepare
17+
uses: Ultimaker/embedded-workflows/.github/workflows/shellcheck.yml@main
18+
secrets: inherit
19+
20+
Flake8:
21+
name: 'Test'
22+
needs: Prepare
23+
uses: Ultimaker/python-quality-control/.github/workflows/flake8.yml@master
24+
with:
25+
PARENT_BRANCH: 'master/s-line'
26+
secrets: inherit
27+
28+
MyPy:
29+
name: 'Test'
30+
needs: Prepare
31+
uses: Ultimaker/python-quality-control/.github/workflows/mypy.yml@master
32+
with:
33+
PARENT_BRANCH: 'master/s-line'
34+
secrets: inherit
35+
36+
PyCodeStyle:
37+
name: 'Test'
38+
needs: Prepare
39+
uses: Ultimaker/python-quality-control/.github/workflows/pycodestyle.yml@master
40+
with:
41+
PARENT_BRANCH: 'master/s-line'
42+
secrets: inherit
43+
44+
Vulture:
45+
name: 'Test'
46+
needs: Prepare
47+
uses: Ultimaker/python-quality-control/.github/workflows/vulture.yml@master
48+
secrets: inherit
49+
50+
PyTest:
51+
name: 'Test'
52+
needs: Prepare
53+
uses: Ultimaker/python-quality-control/.github/workflows/pytest.yml@master
54+
secrets: inherit
55+
56+
Build:
57+
name: 'Build'
58+
needs: Prepare
59+
uses: Ultimaker/embedded-workflows/.github/workflows/build.yml@main
60+
with:
61+
RELEASE_VERSION: ${{ needs.Prepare.outputs.RELEASE_VERSION }}
62+
secrets: inherit
63+
64+
Release_Package:
65+
name: 'Release'
66+
needs: [Prepare, Shellcheck, Build, Flake8, MyPy, PyCodeStyle, Vulture, PyTest]
67+
if: ${{ (success() && needs.Prepare.outputs.RELEASE_REPO != 'none') ||
68+
(failure() && needs.Build.result == 'success' && needs.Prepare.outputs.RELEASE_REPO == 'packages-dev') }}
69+
uses: Ultimaker/embedded-workflows/.github/workflows/release_pkg.yml@main
70+
with:
71+
RELEASE_REPO: ${{ needs.Prepare.outputs.RELEASE_REPO }}
72+
secrets: inherit

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "ci"]
2+
path = ci
3+
url = git@github.com:Ultimaker/python-quality-control.git

build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ build()
2727
create_debian_package()
2828
{
2929
make package
30+
cp ./*.deb ../ || true
3031
}
3132

3233
cleanup()

build_for_ultimaker.sh

Lines changed: 39 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,20 @@
22
#
33
# Copyright (C) 2019 Ultimaker B.V.
44
#
5-
# SPDX-License-Identifier: LGPL-3.0+
65

76
set -eu
87

98
ARCH="armhf"
109

1110
SRC_DIR="$(pwd)"
12-
RELEASE_VERSION="${RELEASE_VERSION:-999.999.999}"
11+
RELEASE_VERSION="${RELEASE_VERSION:-9999.99.99}"
1312
DOCKER_WORK_DIR="/build"
1413
BUILD_DIR_TEMPLATE="_build_${ARCH}"
1514
BUILD_DIR="${BUILD_DIR:-${SRC_DIR}/${BUILD_DIR_TEMPLATE}}"
1615

1716
run_env_check="yes"
18-
run_linters="yes"
19-
run_tests="yes"
20-
21-
# Run the make_docker.sh script here, within the context of the build_for_ultimaker.sh script
22-
. ./make_docker.sh ""
17+
run_verification="yes"
18+
action="none"
2319

2420
env_check()
2521
{
@@ -31,25 +27,11 @@ run_build()
3127
run_in_docker "./build.sh" "${@}"
3228
}
3329

34-
deliver_pkg()
35-
{
36-
run_in_docker chown -R "$(id -u):$(id -g)" "${DOCKER_WORK_DIR}"
37-
38-
cp "${BUILD_DIR}/"*".deb" "./"
39-
}
40-
41-
run_tests()
30+
run_verification()
4231
{
4332
echo "Testing!"
44-
# These tests should never fail! See .gitlab-ci.yml
45-
./run_style_analysis.sh || echo "Code Style Analaysis Failed!"
46-
./run_mypy.sh || echo "MYPY Analysis Failed!"
47-
./run_pytest.sh || echo "PyTest failed!"
48-
}
49-
50-
run_linters()
51-
{
52-
run_shellcheck
33+
# These verifications should never fail! See .gitlab-ci.yml
34+
./ci/local/run_all.sh
5335
}
5436

5537
run_shellcheck()
@@ -67,27 +49,23 @@ usage()
6749
echo "Usage: ${0} [OPTIONS]"
6850
echo " -c Skip build environment checks"
6951
echo " -h Print usage"
70-
echo " -l Skip code linting"
71-
echo " -t Skip tests"
52+
echo " -s Skip code verification"
7253
}
7354

74-
while getopts ":chlst" options; do
55+
while getopts ":a:chls" options; do
7556
case "${options}" in
57+
a)
58+
action="${OPTARG}"
59+
;;
7660
c)
7761
run_env_check="no"
7862
;;
7963
h)
8064
usage
8165
exit 0
8266
;;
83-
l)
84-
run_linters="no"
85-
;;
86-
t)
87-
run_tests="no"
88-
;;
8967
s)
90-
# Ignore for compatibility with other build scripts
68+
run_verification="no"
9169
;;
9270
:)
9371
echo "Option -${OPTARG} requires an argument."
@@ -106,21 +84,40 @@ if ! command -V docker; then
10684
exit 1
10785
fi
10886

87+
case "${action}" in
88+
shellcheck)
89+
run_shellcheck
90+
exit 0
91+
;;
92+
build)
93+
source ./docker_env/make_docker.sh ""
94+
run_build
95+
exit 0
96+
;;
97+
build_docker_cache)
98+
DOCKER_BUILD_ONLY_CACHE="yes"
99+
source ./docker_env/make_docker.sh ""
100+
exit 0
101+
;;
102+
none)
103+
;;
104+
?)
105+
echo "Invalid action: -${OPTARG}"
106+
exit 1
107+
;;
108+
esac
109+
110+
# Make sure to pass an empty argument to make_docker, else any arguments passed to build_for_ultimaker is passed to make_docker instead!
111+
source ./docker_env/make_docker.sh ""
109112

110113
if [ "${run_env_check}" = "yes" ]; then
111114
env_check
112115
fi
113116

114-
if [ "${run_linters}" = "yes" ]; then
115-
run_linters
116-
fi
117-
118117
run_build "${@}"
119118

120-
if [ "${run_tests}" = "yes" ]; then
121-
run_tests
119+
if [ "${run_verification}" = "yes" ]; then
120+
run_verification
122121
fi
123122

124-
deliver_pkg
125-
126123
exit 0

charon_requirements.txt

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1-
typing
2-
pycodestyle
3-
pytest
4-
pytest-cov
1+
flake8==4.0.1
2+
flake8-polyfill==1.0.2
3+
flake8-quotes==3.3.1
4+
mypy==0.910
5+
pep8-naming==0.12.1
6+
pytest==6.2.5
7+
pytest-cov==3.0.0
8+
pytest-mock==1.10.4
9+
pytest-raises==0.11
10+
pytest-profiling==1.7.0
11+
pytest-raises==0.11
12+
vulture==2.3
13+
pycodestyle==2.8.0
14+
pylint==2.13.9
515
coverage
616
lizard
7-
vulture
8-
mypy
17+
typing

ci

Submodule ci added at 58cd8b5

ci/complexity_analysis.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

ci/dead_code_analysis.sh

Lines changed: 0 additions & 7 deletions
This file was deleted.

ci/mypy.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

ci/pytest.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)