Skip to content

Commit dd3e443

Browse files
committed
ci: avoid installing the toolchain from scratch in each job
* Use GitHub Packages * Use container in a step, instead of a container job INSTALL_DIR changed to an absolute location due to actions/runner#1525 Signed-off-by: Unai Martinez-Corral <[email protected]>
1 parent 4d3c60d commit dd3e443

File tree

4 files changed

+94
-38
lines changed

4 files changed

+94
-38
lines changed
Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
from sys import argv as sys_argv
2020

21+
registry = 'ghcr.io/chipsalliance/f4pga/dev/conda'
22+
2123
isFork = len(sys_argv)>1 and sys_argv[1] != 'chipsalliance/f4pga-examples'
2224

2325
runs_on = (
@@ -73,19 +75,36 @@
7375
jobs += [{
7476
'runs-on': runs_on,
7577
'fpga-fam': "xc7",
76-
'os': osver[0],
77-
'os-version': osver[1],
78-
'example': example
78+
'image': f'{registry}/{osver[0]}/{osver[1]}/xc7',
79+
'example': example,
80+
'name': f'xc7 | {osver[0]}/{osver[1]} | {example}'
7981
} for example in examples]
8082

8183
jobs += [{
8284
'runs-on': runs_on,
8385
'fpga-fam': "eos-s3",
84-
'os': osver[0],
85-
'os-version': osver[1],
86-
'example': "counter"
86+
'image': f'{registry}/{osver[0]}/{osver[1]}/eos-s3',
87+
'example': "counter",
88+
'name': f'eos-s3 | {osver[0]}/{osver[1]} | counter',
8789
} for osver in osvers]
8890

89-
print(f'::set-output name=matrix::{jobs!s}')
91+
print('::set-output name=matrix::' + str(jobs))
92+
93+
utils = {
94+
'ubuntu': 'apt -qqy update && apt -qqy install wget locales && locale-gen $LANG',
95+
'debian': 'apt -qqy update && apt -qqy install wget locales && locale-gen $LANG',
96+
'centos': 'yum -y install wget',
97+
'fedora': 'dnf install -y wget'
98+
}
99+
100+
images = [
101+
{
102+
'registry': f'{registry}',
103+
'image': f'{osver[0]}/{osver[1]}/{fam}',
104+
'from': f'{osver[0]}:{osver[1]}',
105+
'utils': utils[osver[0]],
106+
'args': f'{fam} {osver[0]}'
107+
} for osver in osvers for fam in ['xc7', 'eos-s3']
108+
]
90109

91-
print(str(jobs))
110+
print('::set-output name=images::' + str(images))

.github/workflows/sphinx-tuttest.yml

Lines changed: 64 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,61 +13,98 @@ jobs:
1313
runs-on: ubuntu-latest
1414
outputs:
1515
matrix: ${{ steps.generate.outputs.matrix }}
16+
images: ${{ steps.generate.outputs.images }}
1617

1718
steps:
1819

1920
- name: Setup repository
2021
uses: actions/checkout@v2
2122

22-
- name: Generate examples matrix
23+
- name: Generate matrices
2324
id: generate
24-
run: ./.github/scripts/generate_job_matrix.py '${{ github.repository }}'
25+
run: ./.github/scripts/generate_matrices.py '${{ github.repository }}'
2526

2627

27-
Test:
28+
Packages:
2829
needs: Matrix
30+
runs-on: ubuntu-latest
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
include: ${{ fromJson(needs.Matrix.outputs.images) }}
35+
name: 'Image: ${{ matrix.image }}'
36+
env:
37+
DOCKER_BUILDKIT: 1
38+
39+
steps:
40+
41+
- name: Setup repository
42+
uses: actions/checkout@v2
43+
with:
44+
submodules: recursive
45+
46+
- name: Build container image
47+
run: |
48+
docker build -t ${{ matrix.registry }}/${{ matrix.image }} . -f- <<'EOF'
49+
FROM ${{ matrix.from }}
50+
51+
ENV LANG en_US.UTF-8
52+
53+
# Install utils
54+
RUN ${{ matrix.utils }}
55+
56+
# Install tuttest
57+
RUN wget https://github.com/antmicro/tuttest/releases/download/v0.2-beta/tuttest -O /usr/bin/tuttest \
58+
&& chmod a+rx /usr/bin/tuttest
59+
60+
# Install F4PGA toolchain
61+
RUN --mount=type=bind,target=/tmp/ctx cp -vr /tmp/ctx /tmp/repo \
62+
&& cd /tmp/repo && bash /tmp/repo/.github/scripts/install-toolchain.sh ${{ matrix.args }} \
63+
&& cd .. && rm -rf /tmp/repo
64+
EOF
65+
66+
- name: Push container image
67+
uses: pyTooling/Actions/with-post-step@r0
68+
with:
69+
main: |
70+
echo '${{ github.token }}' | docker login ghcr.io -u GitHub-Actions --password-stdin
71+
docker push ${{ matrix.registry }}/${{ matrix.image }}
72+
post: docker logout ghcr.io
73+
74+
75+
Test:
76+
needs:
77+
- Matrix
78+
- Packages
2979
strategy:
3080
fail-fast: false
3181
matrix:
3282
include: ${{ fromJson(needs.Matrix.outputs.matrix) }}
3383
runs-on: ${{ matrix.runs-on }}
34-
name: ${{ matrix.fpga-fam }} | ${{ matrix.os }} ${{ matrix.os-version }} | ${{ matrix.example }}
84+
name: ${{ matrix.name }}
3585

3686
env:
37-
LANG: "en_US.UTF-8"
38-
DEBIAN_FRONTEND: "noninteractive"
3987
GHA_PREEMPTIBLE: "false"
4088

41-
container: ${{matrix.os}}:${{matrix.os-version}}
42-
4389
steps:
44-
- name: Install utils
45-
if: ${{matrix.os == 'ubuntu' || matrix.os == 'debian'}}
46-
run: apt -qqy update && apt -qqy install git wget locales && locale-gen $LANG
47-
48-
- name: Install utils
49-
if: ${{matrix.os == 'centos'}}
50-
run: yum -y install git wget
51-
52-
- name: Install utils
53-
if: ${{matrix.os == 'fedora'}}
54-
run: dnf install -y git wget
5590

5691
- name: Setup repository
5792
uses: actions/checkout@v2
5893
with:
5994
submodules: recursive
6095

61-
- name: Install tuttest
62-
run: |
63-
wget https://github.com/antmicro/tuttest/releases/download/v0.2-beta/tuttest -O /usr/bin/tuttest
64-
chmod a+rx /usr/bin/tuttest
65-
66-
- name: Install F4PGA toolchain
67-
run: bash .github/scripts/install-toolchain.sh ${{matrix.fpga-fam}} ${{matrix.os}}
96+
- name: Pull container image
97+
run: docker pull ${{matrix.image}}
6898

6999
- name: Build examples
70-
run: bash .github/scripts/build-examples.sh ${{matrix.fpga-fam}} ${{matrix.example}}
100+
# Workaround for 'uses: docker://${{matrix.image}}' not being supported.
101+
# See https://github.com/github/feedback/discussions/9049
102+
run: >-
103+
docker run --rm
104+
-v $(pwd):/wrk -w /wrk
105+
-e DEBIAN_FRONTEND="noninteractive"
106+
${{matrix.image}}
107+
bash .github/scripts/build-examples.sh ${{matrix.fpga-fam}} ${{matrix.example}}
71108
72109
- uses: actions/upload-artifact@v2
73110
with:

docs/building-examples.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set it to earlier, for example:
77
.. code-block:: bash
88
:name: export-install-dir
99
10-
export INSTALL_DIR=~/opt/f4pga
10+
export INSTALL_DIR=/opt/f4pga
1111
1212
Select your FPGA family:
1313

@@ -99,7 +99,7 @@ Enter the directory that contains examples for Xilinx 7-Series FPGAs:
9999
:file: templates/example.jinja
100100

101101
.. jinja:: xc7_pulse_width_led
102-
:file: templates/example.jinja
102+
:file: templates/example.jinja
103103

104104

105105

docs/getting-f4pga.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ and so you will need to add some ``sudo`` commands to the instructions below.
8282
.. code-block:: bash
8383
:name: conda-install-dir
8484
85-
export INSTALL_DIR=~/opt/f4pga
85+
export INSTALL_DIR=/opt/f4pga
8686
8787
Toolchain
8888
~~~~~~~~~

0 commit comments

Comments
 (0)