forked from TUDelft-CITG/OpenCLSim
-
Notifications
You must be signed in to change notification settings - Fork 2
108 lines (92 loc) · 3.14 KB
/
actions.yaml
File metadata and controls
108 lines (92 loc) · 3.14 KB
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
name: CI
on:
schedule:
- cron: "5 4 * * SUN"
push:
branches:
- "**"
tags:
- "v*"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
# build the image
build:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# set up build using both layer and buildkit caching following this guide
# https://evilmartians.com/chronicles/build-images-on-github-actions-with-docker-layer-caching
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@master
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-single-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-single-buildx
- name: Build and export
uses: docker/build-push-action@v2
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
file: ./Dockerfile
tags: openclsim:latest
outputs: type=docker,dest=/tmp/image.tar
cache-from: type=gha, scope=${{ github.workflow }}
cache-to: type=gha, scope=${{ github.workflow }}
- name: Upload image to github artifacts
uses: actions/upload-artifact@v2
with:
name: image
path: /tmp/image.tar
retention-days: 5
# test the image in parallel
test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v2
# an explicit pull step is not strictly necessary, but it pulls in parallel
# and in the background while just `running docker-compose up` pulls images one by one
- name: Run docker-compose pull
run: docker-compose pull --ignore-pull-failures -q &
continue-on-error: true
- name: Download image from github artifacts
uses: actions/download-artifact@v2
with:
name: image
path: /tmp
- name: Load image into docker
run: |
docker load --input /tmp/image.tar
docker image ls -a
- name: Run docker-compose up
run: docker-compose -f docker-compose.yml -f docker-compose.test.yml up -d --remove-orphans
- name: Install test dependecies
run: docker-compose exec -T package bash -c "pip install -e .[testing]"
- name: List installed packages
run: docker-compose exec -T package bash -c "pip freeze"
- name: Run tests
run: >-
docker-compose exec -T package bash -c '
pytest \
--cov=src \
--cov=app \
--durations=3 \
--cov-config=setup.cfg \
--cov-context=test \
--black \
--isort \
-W default \
tests src'
- name: Extract coverage from container
run: docker-compose exec -T package bash -c "cat .coverage" > .coverage
- name: Upload coverage
uses: actions/upload-artifact@v2
with:
path: .coverage
retention-days: 1