forked from freeorion/freeorion
-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (78 loc) · 3.08 KB
/
build-docker.yml
File metadata and controls
80 lines (78 loc) · 3.08 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
name: "Dockerized Linux"
on:
push:
paths-ignore:
- 'msvc*/**'
- 'check/**'
- 'doc/**'
- 'packaging/**'
- 'snap/**'
- '*.md'
- 'check/**'
- 'default/**'
- 'test-scripting/**'
pull_request:
paths-ignore:
- 'msvc*/**'
- 'check/**'
- 'doc/**'
- 'packaging/**'
- 'snap/**'
- '*.md'
- 'check/**'
- 'default/**'
- 'test-scripting/**'
jobs:
build-docker:
name: Docker ${{ matrix.image }}
runs-on: ubuntu-latest
strategy:
matrix:
image: [ubuntu-21.04, fedora-32]
env:
CACHE_NAME: linux
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Prepare
id: prep
run: |
TAG=$(echo $GITHUB_SHA | head -c7)
IMAGE="freeorion/freeorion"
echo ::set-output name=tagged_image::${IMAGE}:${TAG}
echo ::set-output name=tag::${TAG}
- uses: satackey/action-docker-layer-caching@v0.0.11
# Ignore the failure of a step and avoid terminating the job.
continue-on-error: true
- name: Build production image
run: |
docker build .github/${{ matrix.image }}/ --file .github/${{ matrix.image }}/Dockerfile --tag ${{ steps.prep.outputs.tagged_image }}
- name: Prepare ccache timestamp
id: build-docker-ccache-timestamp
shell: cmake -P {0}
run: |
string(TIMESTAMP current_date "%Y-%m-%d-%H;%M;%S" UTC)
message("::set-output name=timestamp::${current_date}")
- name: Cache files with ccache
uses: actions/cache@v1.1.0
with:
path: ${{ runner.temp }}/ccache
key: build-${{ matrix.image }}-docker-ccache-${{ steps.build-docker-ccache-timestamp.outputs.timestamp }}
restore-keys: |
build-${{ matrix.image }}-docker-ccache-
- name: Configure freeorion
if: ${{ matrix.image == 'ubuntu-21.04' }}
run: |
mkdir build
docker run -v "$(pwd):/freeorion" -v "${{ runner.temp }}/ccache:/ccache_dir" -e CCACHE_DIR='/ccache_dir' -w /freeorion/build ${{ steps.prep.outputs.tagged_image }} /usr/bin/cmake -DBUILD_TESTING=ON -DCMAKE_C_COMPILER=gcc-11 -DCMAKE_CXX_COMPILER=g++-11 ..
- name: Configure freeorion
if: ${{ matrix.image == 'fedora-32' }}
run: |
mkdir build
docker run -v "$(pwd):/freeorion" -v "${{ runner.temp }}/ccache:/ccache_dir" -e CCACHE_DIR='/ccache_dir' -w /freeorion/build ${{ steps.prep.outputs.tagged_image }} /usr/bin/cmake -DBUILD_TESTING=ON ..
- name: Build freeorion
run: |
docker run -v "$(pwd):/freeorion" -v "${{ runner.temp }}/ccache:/ccache_dir" -e CCACHE_DIR='/ccache_dir' -w /freeorion/build ${{ steps.prep.outputs.tagged_image }} /usr/bin/cmake --build . -- -j 2
- name: Test freeorion
run: |
docker run -v "$(pwd):/freeorion" -v "${{ runner.temp }}/ccache:/ccache_dir" -e CCACHE_DIR='/ccache_dir' -e FO_TEST_HOSTLESS_GAMES=1 -w /freeorion/build ${{ steps.prep.outputs.tagged_image }} /usr/bin/cmake --build . --target unittest