github: Remove github.ref from cache keys
[strongswan.git] / .github / workflows / linux.yml
1 name: Linux
2
3 on: [push, pull_request]
4
5 env:
6   # this test case does not actually test anything but tries to access system
7   # directories that might be inaccessible on build hosts
8   TESTS_CASES_EXCLUDE: sw_collector
9   TESTS_REDUCED_KEYLENGTHS: yes
10   CCACHE_BASEDIR: ${{ github.workspace }}
11   CCACHE_COMPRESS: true
12   CCACHE_MAXSIZE: 200M
13   OS_NAME: linux
14
15 jobs:
16   pre-check:
17     runs-on: ubuntu-latest
18     outputs:
19       should_skip: ${{ steps.skip-check.outputs.should_skip }}
20     steps:
21       - id: skip-check
22         uses: fkirc/skip-duplicate-actions@master
23         with:
24           concurrent_skipping: 'same_content'
25
26   latest:
27     needs: pre-check
28     if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
29     runs-on: ubuntu-latest
30     strategy:
31       matrix:
32         test: [ all, default, printf-builtin ]
33         compiler: [ gcc, clang ]
34         leak-detective: [ no, yes ]
35         monolithic: [ no, yes ]
36         exclude:
37           # leaks will show up whether we build monolithic or not
38           - leak-detective: yes
39             monolithic: yes
40           # monolithic builds don't affect the printf-hook implementation
41           - test: printf-builtin
42             monolithic: yes
43         include:
44           - test: apidoc
45           - test: coverage
46           - test: dist
47           - test: nm-no-glib
48           - test: fuzzing
49             compiler: clang
50             monolithic: yes
51     env:
52       LEAK_DETECTIVE: ${{ matrix.leak-detective || 'no' }}
53       MONOLITHIC: ${{ matrix.monolithic || 'no' }}
54       CC: ${{ matrix.compiler || 'gcc' }}
55       TEST: ${{ matrix.test }}
56     steps:
57       - uses: actions/checkout@v2
58       - uses: actions/cache@v2
59         with:
60           path: ~/.ccache
61           # with regards to ccache, monolithic builds don't differ from regular
62           # builds and, similarly, builds with leak-detective only differ in two
63           # files (LD itself and library.c); but different tests build different
64           # dependencies, so different caches are needed
65           key: ccache-${{ runner.os }}-${{ env.CC }}-${{ matrix.test }}-${{ github.sha }}
66           restore-keys: |
67             ccache-${{ runner.os }}-${{ env.CC }}-${{ matrix.test }}-
68             ccache-${{ runner.os }}-${{ env.CC }}-
69       - run: |
70           sudo apt-get install -qq ccache
71           echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
72           ccache -z
73       - uses: ./.github/actions/default
74       - run: ccache -s
75       - if: ${{ success() && matrix.test == 'coverage' }}
76         run: bash <(curl -s https://codecov.io/bash)
77       - if: ${{ failure() }}
78         uses: actions/upload-artifact@v2
79         with:
80           name: Logs ${{ github.job }}
81           path: config.log
82           retention-days: 5
83
84   crypto-plugins:
85     needs: pre-check
86     if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
87     runs-on: ubuntu-latest
88     strategy:
89       matrix:
90         test: [ botan, wolfssl, openssl, gcrypt ]
91         leak-detective: [ no, yes ]
92     env:
93       LEAK_DETECTIVE: ${{ matrix.leak-detective || 'no' }}
94       TEST: ${{ matrix.test }}
95     steps:
96       - uses: actions/checkout@v2
97       - uses: actions/cache@v2
98         with:
99           path: ~/.ccache
100           key: ccache-${{ runner.os }}-${{ env.CC }}-${{ matrix.test }}-${{ github.sha }}
101           restore-keys: |
102             ccache-${{ runner.os }}-${{ env.CC }}-${{ matrix.test }}-
103             ccache-${{ runner.os }}-${{ env.CC }}-
104             ccache-${{ runner.os }}-${{ env.CC }}-all-${{ github.sha }}
105             ccache-${{ runner.os }}-${{ env.CC }}-all-
106             ccache-${{ runner.os }}-${{ env.CC }}-
107       - run: |
108           sudo apt-get install -qq ccache
109           echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
110           ccache -z
111       - uses: ./.github/actions/default
112       - run: ccache -s
113       - if: ${{ failure() }}
114         uses: actions/upload-artifact@v2
115         with:
116           name: Logs ${{ github.job }}
117           path: config.log
118           retention-days: 5
119
120   bionic:
121     needs: pre-check
122     if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
123     runs-on: ubuntu-18.04
124     strategy:
125       matrix:
126         test: [ all ]
127         compiler: [ gcc, clang ]
128         include:
129           - test: nm
130     env:
131       LEAK_DETECTIVE: ${{ matrix.leak-detective || 'no' }}
132       CC: ${{ matrix.compiler || 'gcc' }}
133       TEST: ${{ matrix.test }}
134       UBUNTU_BIONIC: yes
135     steps:
136       - uses: actions/checkout@v2
137       - uses: actions/cache@v2
138         with:
139           path: ~/.ccache
140           key: ccache-bionic-${{ env.CC }}-${{ matrix.test }}-${{ github.sha }}
141           restore-keys: |
142             ccache-bionic-${{ env.CC }}-${{ matrix.test }}-
143             ccache-bionic-${{ env.CC }}-
144       - run: |
145           sudo apt-get install -qq ccache
146           echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
147           ccache -z
148       - uses: ./.github/actions/default
149       - run: ccache -s
150       - if: ${{ failure() }}
151         uses: actions/upload-artifact@v2
152         with:
153           name: Logs ${{ github.job }}
154           path: config.log
155           retention-days: 5
156
157   xenial:
158     needs: pre-check
159     if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
160     runs-on: ubuntu-16.04
161     strategy:
162       matrix:
163         test: [ all ]
164         compiler: [ gcc, clang ]
165         include:
166           - test: openssl-1.0
167           - test: openssl-1.0
168             leak-detective: yes
169     env:
170       LEAK_DETECTIVE: ${{ matrix.leak-detective || 'no' }}
171       CC: ${{ matrix.compiler || 'gcc' }}
172       TEST: ${{ matrix.test }}
173       # this is the default with newer versions and fixes builds with clang
174       CCACHE_CPP2: true
175     steps:
176       - uses: actions/checkout@v2
177       - uses: actions/cache@v2
178         with:
179           path: ~/.ccache
180           key: ccache-xenial-${{ env.CC }}-${{ matrix.test }}-${{ github.sha }}
181           restore-keys: |
182             ccache-xenial-${{ env.CC }}-${{ matrix.test }}-
183             ccache-xenial-${{ env.CC }}-
184       - run: |
185           sudo apt-get install -qq ccache
186           echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
187           ccache -z
188       - uses: ./.github/actions/default
189       - run: ccache -s
190       - if: ${{ failure() }}
191         uses: actions/upload-artifact@v2
192         with:
193           name: Logs ${{ github.job }}
194           path: config.log
195           retention-days: 5