-
Notifications
You must be signed in to change notification settings - Fork 6
76 lines (64 loc) · 2.63 KB
/
dockerfile-test-v1.0.1.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
name: v1.0.1 Dockerfile
on: [push, pull_request, workflow_dispatch]
env:
DOCKERFILE_NAME: "bioslam1.0.1-gtsam4.0.3-ubu20.Dockerfile"
jobs:
duplicate_job_check:
# continue-on-error: true # Uncomment once integration is finished
runs-on: ubuntu-20.04
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/[email protected]
with:
concurrent_skipping: "same_content_newer"
skip_after_successful_duplicate: "true"
paths_ignore: '["**/README.md", "**/docs/**"]'
do_not_skip: '["workflow_dispatch", "schedule"]'
conditional_check_dockerfile_changed:
needs: duplicate_job_check
if: needs.duplicate_job_check.outputs.should_skip != 'true'
runs-on: ubuntu-latest
# Declare outputs for next jobs
outputs:
file_changed: ${{ steps.check_file_changed.outputs.file_changed }}
steps:
- name: print skip check results
run: echo "should_skip=${{ needs.duplicate_job_check.outputs.should_skip }}, reason is ${{ needs.duplicate_job_check.outputs.reason }}"
- uses: actions/checkout@v3
with:
# Checkout as many commits as needed for the diff
fetch-depth: 2
- id: check_file_changed
name: Check if Dockerfile changed
run: |
# Diff HEAD with the previous commit (a list of changed files)
diff=$(git diff --name-only HEAD^ HEAD)
# check if the Dockerfile at docker/$DOCKERFILE_NAME is in the diff
# Use || true to prevent failure if grep doesn't find a match
DockerfileDiff=$(echo "$diff" | grep "docker/$DOCKERFILE_NAME" || true)
# if the Dockerfile is in the diff, then set HasDiff to True
if [ -z "$DockerfileDiff" ]; then
HasDiff="False"
else
HasDiff="True"
fi
# echo the output to $GITHUB_OUTPUT
echo "file_changed=$HasDiff" >> "$GITHUB_OUTPUT"
- name: print if file changed
run: echo "file_changed=${{ steps.check_file_changed.outputs.file_changed }}"
test:
name: Test Dockerfile
runs-on: ubuntu-latest
needs: conditional_check_dockerfile_changed
if: needs.conditional_check_dockerfile_changed.outputs.file_changed == 'True'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build and run docker image
run: |
docker build -t bioslam -f ./docker/$DOCKERFILE_NAME ./docker
docker run -id --name bioslam bioslam
- name: Run tests
run: docker exec -i bioslam bash -c "export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib && cd /usr/src/bioslam/build && make test"