github: Make LGTM project ID configurable via environment variable
[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.ref }}:${{ github.sha }}
66           restore-keys: |
67             ccache-${{ runner.os }}-${{ env.CC }}-${{ matrix.test }}-${{ github.ref }}:
68             ccache-${{ runner.os }}-${{ env.CC }}-${{ matrix.test }}-
69             ccache-${{ runner.os }}-${{ env.CC }}-
70       - run: |
71           sudo apt-get install -qq ccache
72           echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
73           ccache -z
74       - uses: ./.github/actions/default
75       - run: ccache -s
76       - if: ${{ success() && matrix.test == 'coverage' }}
77         run: bash <(curl -s https://codecov.io/bash)
78       - if: ${{ failure() }}
79         uses: actions/upload-artifact@v2
80         with:
81           name: Logs ${{ github.job }}
82           path: config.log
83           retention-days: 5
84
85   crypto-plugins:
86     needs: pre-check
87     if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
88     runs-on: ubuntu-latest
89     strategy:
90       matrix:
91         test: [ botan, wolfssl, openssl, gcrypt ]
92         leak-detective: [ no, yes ]
93     env:
94       LEAK_DETECTIVE: ${{ matrix.leak-detective || 'no' }}
95       TEST: ${{ matrix.test }}
96     steps:
97       - uses: actions/checkout@v2
98       - uses: actions/cache@v2
99         with:
100           path: ~/.ccache
101           key: ccache-${{ runner.os }}-${{ env.CC }}-${{ matrix.test }}-${{ github.ref }}:${{ github.sha }}
102           restore-keys: |
103             ccache-${{ runner.os }}-${{ env.CC }}-${{ matrix.test }}-${{ github.ref }}:
104             ccache-${{ runner.os }}-${{ env.CC }}-${{ matrix.test }}-
105             ccache-${{ runner.os }}-${{ env.CC }}-
106             ccache-${{ runner.os }}-${{ env.CC }}-all-${{ github.ref }}:${{ github.sha }}
107             ccache-${{ runner.os }}-${{ env.CC }}-all-${{ github.ref }}:
108             ccache-${{ runner.os }}-${{ env.CC }}-all-
109             ccache-${{ runner.os }}-${{ env.CC }}-
110       - run: |
111           sudo apt-get install -qq ccache
112           echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
113           ccache -z
114       - uses: ./.github/actions/default
115       - run: ccache -s
116       - if: ${{ failure() }}
117         uses: actions/upload-artifact@v2
118         with:
119           name: Logs ${{ github.job }}
120           path: config.log
121           retention-days: 5
122
123   bionic:
124     needs: pre-check
125     if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
126     runs-on: ubuntu-18.04
127     strategy:
128       matrix:
129         test: [ all ]
130         compiler: [ gcc, clang ]
131         include:
132           - test: nm
133     env:
134       LEAK_DETECTIVE: ${{ matrix.leak-detective || 'no' }}
135       CC: ${{ matrix.compiler || 'gcc' }}
136       TEST: ${{ matrix.test }}
137       UBUNTU_BIONIC: yes
138     steps:
139       - uses: actions/checkout@v2
140       - uses: actions/cache@v2
141         with:
142           path: ~/.ccache
143           key: ccache-bionic-${{ env.CC }}-${{ matrix.test }}-${{ github.ref }}:${{ github.sha }}
144           restore-keys: |
145             ccache-bionic-${{ env.CC }}-${{ matrix.test }}-${{ github.ref }}:
146             ccache-bionic-${{ env.CC }}-${{ matrix.test }}-
147             ccache-bionic-${{ env.CC }}-
148       - run: |
149           sudo apt-get install -qq ccache
150           echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
151           ccache -z
152       - uses: ./.github/actions/default
153       - run: ccache -s
154       - if: ${{ failure() }}
155         uses: actions/upload-artifact@v2
156         with:
157           name: Logs ${{ github.job }}
158           path: config.log
159           retention-days: 5
160
161   xenial:
162     needs: pre-check
163     if: ${{ needs.pre-check.outputs.should_skip != 'true' }}
164     runs-on: ubuntu-16.04
165     strategy:
166       matrix:
167         test: [ all ]
168         compiler: [ gcc, clang ]
169         include:
170           - test: openssl-1.0
171           - test: openssl-1.0
172             leak-detective: yes
173     env:
174       LEAK_DETECTIVE: ${{ matrix.leak-detective || 'no' }}
175       CC: ${{ matrix.compiler || 'gcc' }}
176       TEST: ${{ matrix.test }}
177       # this is the default with newer versions and fixes builds with clang
178       CCACHE_CPP2: true
179     steps:
180       - uses: actions/checkout@v2
181       - uses: actions/cache@v2
182         with:
183           path: ~/.ccache
184           key: ccache-xenial-${{ env.CC }}-${{ matrix.test }}-${{ github.ref }}:${{ github.sha }}
185           restore-keys: |
186             ccache-xenial-${{ env.CC }}-${{ matrix.test }}-${{ github.ref }}:
187             ccache-xenial-${{ env.CC }}-${{ matrix.test }}-
188             ccache-xenial-${{ env.CC }}-
189       - run: |
190           sudo apt-get install -qq ccache
191           echo "PATH=/usr/lib/ccache:$PATH" >> $GITHUB_ENV
192           ccache -z
193       - uses: ./.github/actions/default
194       - run: ccache -s
195       - if: ${{ failure() }}
196         uses: actions/upload-artifact@v2
197         with:
198           name: Logs ${{ github.job }}
199           path: config.log
200           retention-days: 5