@@ -17,26 +17,51 @@ jobs:
17
17
build-and-test :
18
18
runs-on : ubuntu-latest
19
19
steps :
20
- - uses : actions/checkout@v1
21
- - uses : satackey/action-docker-layer-caching@v0.0.11
22
- continue-on-error : true # ignore the failure of a step and avoid terminating the job
23
- - name : Run Docker build
24
- run : |
25
- docker build \
26
- --target gobuild \
27
- --tag go-build-env .
28
- docker build \
29
- --tag keep-client .
20
+ - uses : actions/checkout@v2
21
+
22
+ - name : Set up Docker Buildx
23
+ uses : docker/setup-buildx-action@v1
24
+
25
+ - name : Cache Docker layers
26
+ uses : actions/cache@v2
27
+ with :
28
+ path : /tmp/.buildx-cache
29
+ key : ${{ runner.os }}-buildx-${{ github.sha }}
30
+ restore-keys : |
31
+ ${{ runner.os }}-buildx-
32
+
33
+ # TODO: This step was left here intentionally so we can track disk space
34
+ # usage for a while. We were trying to fight problems with out of disk space
35
+ # that happened due to the size of data restored from cache. The cache size
36
+ # was growing linearly with subsequent workflow runs. We want to observe
37
+ # available disk space for `/`. Fresh execution starts with 20 GB, we expect
38
+ # to have no less than 15 GB after the cache is restored.
39
+ - run : sudo df -h
40
+
41
+ - name : Build Docker Build Image
42
+ uses : docker/build-push-action@v2
43
+ with :
44
+ target : gobuild
45
+ tags : go-build-env
46
+ build-args : |
47
+ REVISION=${{ github.sha }}
48
+ # VERSION= ? TODO: Configure version, sample: 1.7.6
49
+ load : true # load image to local registry to use it in next steps
50
+ cache-from : type=local,src=/tmp/.buildx-cache
51
+ cache-to : type=local,dest=/tmp/.buildx-cache
52
+
30
53
- name : Create test results directory
31
54
run : |
32
55
mkdir test-results
56
+
33
57
- name : Run Go tests
34
58
run : |
35
59
docker run \
36
60
--volume $GITHUB_WORKSPACE/test-results:/mnt/test-results \
37
61
--workdir /go/src/github.com/keep-network/keep-core \
38
62
go-build-env \
39
63
gotestsum --junitfile /mnt/test-results/unit-tests.xml
64
+
40
65
- name : Publish unit test results
41
66
uses : EnricoMi/publish-unit-test-result-action@v1.7
42
67
if : always() # guarantees that this action always runs, even if earlier steps fail
45
70
files : ./test-results/unit-tests.xml
46
71
check_name : Go Test Results # name under which test results will be presented in GitHub (optional)
47
72
comment_on_pr : false # turns off commenting on Pull Requests
73
+
74
+ # This step is executed after the tests as we want to configure it eventually
75
+ # as image publication step.
76
+ - name : Build Docker Runtime Image
77
+ uses : docker/build-push-action@v2
78
+ with :
79
+ tags : keep-client
80
+ labels : |
81
+ revision=${{ github.sha }}
82
+ # TODO: Check branch name and publish to a registry accordingly to the
83
+ # environment.
84
+ # push: true # publish to registry
0 commit comments