forked from epfl-lasa/control-libraries
-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (101 loc) · 4.06 KB
/
build-test.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
name: Build and Test
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
check-changelog:
name: Check if changelog has been updated
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check changelog
if: ${{ github.event.pull_request.base.sha }}
run: |
git fetch origin main ${{ github.event.pull_request.base.sha }}
CL_DIFF=$(git diff ${{ github.event.pull_request.base.sha }} ${{ github.sha }} -- CHANGELOG.md)
if ! [ "${CL_DIFF}" ]; then
echo "::error file="CHANGELOG.md",title=Check failed::CHANGELOG.md must be updated!"
exit 1
fi
shell: bash
check-version:
name: Check if version has been updated
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check version
if: ${{ github.event.pull_request.base.sha }}
run: |
VERSION=$(echo $(<VERSION) | tr -d -c 0-9)
MESSAGE="Set the desired version correctly using the 'update_version' script!"
SOURCE_CMAKE="./source/CMakeLists.txt"
if [ $(echo $(grep "project(control_libraries VERSION" "${SOURCE_CMAKE}") | tr -d -c 0-9) -ne "${VERSION}" ]; then
echo "::error file="${SOURCE_CMAKE}",title=Check failed::Version in "${SOURCE_CMAKE}" does not correspond to VERSION. ${MESSAGE}"
exit 1
fi
PROTO_CMAKE="./protocol/clproto_cpp/CMakeLists.txt"
if [ $(echo $(grep "project(clproto VERSION" "${PROTO_CMAKE}") | tr -d -c 0-9) -ne "${VERSION}" ]; then
echo "::error file="${PROTO_CMAKE}",title=Check failed::Version in "${PROTO_CMAKE}" does not correspond to VERSION. ${MESSAGE}"
exit 1
fi
PY_SETUP="./python/setup.py"
if [ $(echo $(grep "__version__ =" "${PY_SETUP}") | tr -d -c 0-9) -ne "${VERSION}" ]; then
echo "::error file="${PY_SETUP}",title=Check failed::Version in "${PY_SETUP}" does not correspond to VERSION. ${MESSAGE}"
exit 1
fi
DOXY="./doxygen/doxygen.conf"
if [ $(echo $(echo $(grep "PROJECT_NUMBER =" "${DOXY}") | tr -d -c 0-9) | tr -d '\0' ) -ne "${VERSION}" ]; then
echo "::error file="${DOXY}",title=Check failed::Version in "${DOXY}" does not correspond to VERSION. ${MESSAGE}"
exit 1
fi
DEMO_CMAKE="./demos/CMakeLists.txt"
if [ $(echo $(grep "find_package(control_libraries" "${DEMO_CMAKE}") | tr -d -c 0-9) -ne "${VERSION}" ]; then
echo "::error file="${DEMO_CMAKE}",title=Check failed::Version in "${DEMO_CMAKE}" does not correspond to VERSION. ${MESSAGE}"
exit 1
fi
shell: bash
check-skippable-changes:
name: Check skippable changes
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.check_if_skippable.outputs.should_skip }}
steps:
- id: check_if_skippable
uses: fkirc/skip-duplicate-actions@master
with:
cancel_others: 'true'
do_not_skip: '["workflow_dispatch"]'
paths_ignore: '["**.md", ".**/**", "**.gitignore"]'
skip_after_successful_duplicate: 'true'
build-test:
needs: check-skippable-changes
if: ${{ needs.check-skippable-changes.outputs.skip != 'true' }}
runs-on: ubuntu-latest
name: Run tests
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Cache for Docker
uses: actions/cache@v3
with:
path: build-cache
key: ${{ runner.os }}-build-cache-${{ hashFiles('./') }}
- name: Inject build-cache into docker
uses: reproducible-containers/[email protected]
with:
cache-source: build-cache
cache-target: /build
- name: Build and Test
uses: docker/build-push-action@v5
with:
context: .
target: python-test
cache-from: type=gha
cache-to: type=gha,mode=max