Skip to content

Commit 75f01cc

Browse files
authored
Merge pull request #4183 from YosysHQ/krys/refactor-workflows
CI Improvements
2 parents 1f51362 + 5e6bb45 commit 75f01cc

File tree

9 files changed

+296
-301
lines changed

9 files changed

+296
-301
lines changed
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Build environment setup
2+
description: Configure build env for Yosys builds
3+
runs:
4+
using: composite
5+
steps:
6+
- name: Install Linux Dependencies
7+
if: runner.os == 'Linux'
8+
shell: bash
9+
run: |
10+
sudo apt-get update
11+
sudo apt-get install gperf build-essential bison flex libreadline-dev gawk tcl-dev libffi-dev git graphviz xdot pkg-config python3 libboost-system-dev libboost-python-dev libboost-filesystem-dev zlib1g-dev
12+
13+
- name: Install macOS Dependencies
14+
if: runner.os == 'macOS'
15+
shell: bash
16+
run: |
17+
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew install bison flex gawk libffi pkg-config bash autoconf
18+
19+
- name: Linux runtime environment
20+
if: runner.os == 'Linux'
21+
shell: bash
22+
run: |
23+
echo "${{ github.workspace }}/.local/bin" >> $GITHUB_PATH
24+
echo "procs=$(nproc)" >> $GITHUB_ENV
25+
26+
- name: macOS runtime environment
27+
if: runner.os == 'macOS'
28+
shell: bash
29+
run: |
30+
echo "${{ github.workspace }}/.local/bin" >> $GITHUB_PATH
31+
echo "$(brew --prefix bison)/bin" >> $GITHUB_PATH
32+
echo "$(brew --prefix flex)/bin" >> $GITHUB_PATH
33+
echo "procs=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV

.github/workflows/test-build.yml

+172
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
name: Build and run tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
pre_job:
7+
runs-on: ubuntu-latest
8+
outputs:
9+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
10+
steps:
11+
- id: skip_check
12+
uses: fkirc/skip-duplicate-actions@v5
13+
with:
14+
paths_ignore: '["**/README.md", "docs/**", "guidelines/**"]'
15+
# cancel previous builds if a new commit is pushed
16+
cancel_others: 'true'
17+
# only run on push *or* pull_request, not both
18+
concurrent_skipping: 'same_content_newer'
19+
20+
build-yosys:
21+
name: Reusable build
22+
runs-on: ${{ matrix.os }}
23+
needs: pre_job
24+
if: needs.pre_job.outputs.should_skip != 'true'
25+
env:
26+
CC: clang
27+
strategy:
28+
matrix:
29+
os: [ubuntu-latest, macos-latest]
30+
fail-fast: false
31+
steps:
32+
- name: Checkout Yosys
33+
uses: actions/checkout@v4
34+
with:
35+
submodules: true
36+
37+
- name: Setup environment
38+
uses: ./.github/actions/setup-build-env
39+
40+
- name: Build
41+
shell: bash
42+
run: |
43+
mkdir build
44+
cd build
45+
make -f ../Makefile config-$CC
46+
make -f ../Makefile -j$procs
47+
48+
- name: Log yosys-config output
49+
run: |
50+
./yosys-config || true
51+
52+
- name: Log yosys-config output
53+
run: |
54+
./yosys-config || true
55+
56+
- name: Compress build
57+
shell: bash
58+
run: |
59+
cd build
60+
tar -cvf ../build.tar share/ yosys yosys-*
61+
62+
- name: Store build artifact
63+
uses: actions/upload-artifact@v4
64+
with:
65+
name: build-${{ matrix.os }}
66+
path: build.tar
67+
retention-days: 1
68+
69+
test-yosys:
70+
name: Run tests
71+
runs-on: ${{ matrix.os }}
72+
needs: [build-yosys, pre_job]
73+
if: needs.pre_job.outputs.should_skip != 'true'
74+
env:
75+
CC: clang
76+
strategy:
77+
matrix:
78+
os: [ubuntu-latest, macos-latest]
79+
fail-fast: false
80+
steps:
81+
- name: Checkout Yosys
82+
uses: actions/checkout@v4
83+
84+
- name: Setup environment
85+
uses: ./.github/actions/setup-build-env
86+
87+
- name: Get iverilog
88+
shell: bash
89+
run: |
90+
git clone https://github.com/steveicarus/iverilog.git
91+
cd iverilog
92+
echo "IVERILOG_GIT=$(git rev-parse HEAD)" >> $GITHUB_ENV
93+
94+
- name: Cache iverilog
95+
id: cache-iverilog
96+
uses: actions/cache@v4
97+
with:
98+
path: .local/
99+
key: ${{ matrix.os }}-${{ env.IVERILOG_GIT }}
100+
101+
- name: Build iverilog
102+
if: steps.cache-iverilog.outputs.cache-hit != 'true'
103+
shell: bash
104+
run: |
105+
mkdir -p ${{ github.workspace }}/.local/
106+
cd iverilog
107+
autoconf
108+
CC=gcc CXX=g++ ./configure --prefix=${{ github.workspace }}/.local
109+
make -j$procs
110+
make install
111+
112+
- name: Download build artifact
113+
uses: actions/download-artifact@v4
114+
with:
115+
name: build-${{ matrix.os }}
116+
117+
- name: Uncompress build
118+
shell: bash
119+
run:
120+
tar -xvf build.tar
121+
122+
- name: Log yosys-config output
123+
run: |
124+
./yosys-config || true
125+
126+
- name: Run tests
127+
shell: bash
128+
run: |
129+
make -j$procs test TARGETS= EXTRA_TARGETS= CONFIG=$CC
130+
131+
- name: Report errors
132+
if: ${{ failure() }}
133+
shell: bash
134+
run: |
135+
find tests/**/*.err -print -exec cat {} \;
136+
137+
test-docs:
138+
name: Run docs tests
139+
runs-on: ${{ matrix.os }}
140+
needs: [build-yosys, pre_job]
141+
if: needs.pre_job.outputs.should_skip != 'true'
142+
env:
143+
CC: clang
144+
strategy:
145+
matrix:
146+
os: [ubuntu-latest]
147+
fail-fast: false
148+
steps:
149+
- name: Checkout Yosys
150+
uses: actions/checkout@v4
151+
152+
- name: Setup environment
153+
uses: ./.github/actions/setup-build-env
154+
155+
- name: Download build artifact
156+
uses: actions/download-artifact@v4
157+
with:
158+
name: build-${{ matrix.os }}
159+
160+
- name: Uncompress build
161+
shell: bash
162+
run:
163+
tar -xvf build.tar
164+
165+
- name: Log yosys-config output
166+
run: |
167+
./yosys-config || true
168+
169+
- name: Run tests
170+
shell: bash
171+
run: |
172+
make -C docs test -j${{ env.procs }}

.github/workflows/test-compile.yml

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Compiler testing
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
pre_job:
7+
runs-on: ubuntu-latest
8+
outputs:
9+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
10+
steps:
11+
- id: skip_check
12+
uses: fkirc/skip-duplicate-actions@v5
13+
with:
14+
paths_ignore: '["**/README.md", "docs/**", "guidelines/**"]'
15+
# cancel previous builds if a new commit is pushed
16+
cancel_others: 'true'
17+
# only run on push *or* pull_request, not both
18+
concurrent_skipping: 'same_content_newer'
19+
20+
test-compile:
21+
runs-on: ${{ matrix.os }}
22+
needs: pre_job
23+
if: needs.pre_job.outputs.should_skip != 'true'
24+
env:
25+
CXXFLAGS: ${{ startsWith(matrix.compiler, 'gcc') && '-Wp,-D_GLIBCXX_ASSERTIONS' || ''}}
26+
CC_SHORT: ${{ startsWith(matrix.compiler, 'gcc') && 'gcc' || 'clang' }}
27+
strategy:
28+
matrix:
29+
os:
30+
- ubuntu-latest
31+
compiler:
32+
# oldest supported
33+
- 'clang-14'
34+
- 'gcc-10'
35+
# newest
36+
- 'clang'
37+
- 'gcc'
38+
include:
39+
# macOS
40+
- os: macos-13
41+
compiler: 'clang'
42+
# oldest clang not available on ubuntu-latest
43+
- os: ubuntu-22.04
44+
compiler: 'clang-11'
45+
fail-fast: false
46+
steps:
47+
- name: Checkout Yosys
48+
uses: actions/checkout@v4
49+
with:
50+
submodules: true
51+
52+
- name: Setup environment
53+
uses: ./.github/actions/setup-build-env
54+
55+
- name: Setup Cpp
56+
uses: aminya/setup-cpp@v1
57+
with:
58+
compiler: ${{ matrix.compiler }}
59+
60+
- name: Tool versions
61+
shell: bash
62+
run: |
63+
$CC --version
64+
$CXX --version
65+
66+
# minimum standard
67+
- name: Build C++11
68+
shell: bash
69+
run: |
70+
make config-$CC_SHORT
71+
make -j$procs CXXSTD=c++11 compile-only
72+
73+
# maximum standard, only on newest compilers
74+
- name: Build C++20
75+
if: ${{ matrix.compiler == 'clang' || matrix.compiler == 'gcc'}}
76+
shell: bash
77+
run: |
78+
make config-$CC_SHORT
79+
make -j$procs CXXSTD=c++20 compile-only

.github/workflows/test-docs.yml

-58
This file was deleted.

0 commit comments

Comments
 (0)