Skip to content

Commit

Permalink
ci: rework variables in container pipeline
Browse files Browse the repository at this point in the history
Signed-off-by: David Marchand <[email protected]>
  • Loading branch information
david-marchand committed Oct 24, 2024
1 parent 90cb8ff commit 1aa3009
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -164,18 +164,26 @@ jobs:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.get_keys.outputs.image }}
os: ${{ matrix.config.os }}
pkgs: ${{ steps.get_keys.outputs.pkgs }}

strategy:
fail-fast: false
matrix:
config:
- image: fedora:39
- os: fedora:39

steps:
- name: Generate various keys
id: get_keys
run: |
echo 'image=image-${{ matrix.config.image }}-'$(date -u +%Y-%m-%d) >> $GITHUB_OUTPUT
echo 'image=image-${{ matrix.config.os }}-'$(date -u +%Y-%m-%d) >> $GITHUB_OUTPUT
pkgs="$pkgs ccache intel-ipsec-mb-devel isa-l-devel jansson-devel libarchive-devel"
pkgs="$pkgs libatomic libbsd-devel libbpf-devel libfdt-devel libpcap-devel libxdp-devel"
pkgs="$pkgs ninja-build numactl-devel openssl-devel python3-pip python3-pyelftools"
pkgs="$pkgs python3-setuptools python3-wheel rdma-core-devel zlib-devel"
echo 'pkgs='$pkgs >> $GITHUB_OUTPUT
- name: Retrieve image cache
id: image_cache
uses: actions/cache@v4
Expand All @@ -185,26 +193,22 @@ jobs:
- name: Pull and prepare a fresh image
if: steps.image_cache.outputs.cache-hit != 'true'
run: |
docker pull registry.fedoraproject.org/${{ matrix.config.image }}
docker pull registry.fedoraproject.org/${{ matrix.config.os }}
docker run -d -i --rm --name dpdk \
registry.fedoraproject.org/${{ matrix.config.image }} \
registry.fedoraproject.org/${{ matrix.config.os }} \
bash -li
- name: Update
if: steps.image_cache.outputs.cache-hit != 'true'
run: docker exec -i dpdk dnf update -y
- name: Install packages
if: steps.image_cache.outputs.cache-hit != 'true'
run: docker exec -i dpdk dnf install -y ccache intel-ipsec-mb-devel
isa-l-devel jansson-devel libarchive-devel libatomic libbsd-devel
libbpf-devel libfdt-devel libpcap-devel libxdp-devel ninja-build
numactl-devel openssl-devel python3-pip python3-pyelftools
python3-setuptools python3-wheel rdma-core-devel zlib-devel
run: docker exec -i dpdk dnf install -y ${{ steps.get_keys.outputs.pkgs }}
- name: Save image in cache
if: steps.image_cache.outputs.cache-hit != 'true'
run: |
docker commit dpdk dpdk-local
mkdir -p ~/.image
docker save -o ~/.image/${{ matrix.config.image }}.tar dpdk-local
docker save -o ~/.image/${{ matrix.config.os }}.tar dpdk-local
- name: Stop image
if: steps.image_cache.outputs.cache-hit != 'true'
run: docker kill dpdk
Expand All @@ -218,9 +222,9 @@ jobs:
fail-fast: false
matrix:
config:
- image: fedora:39
- os: needs.prepare-container-images.outputs.os
compiler: gcc
- image: fedora:39
- os: needs.prepare-container-images.outputs.os
compiler: clang

steps:
Expand All @@ -229,18 +233,19 @@ jobs:
- name: Generate various keys
id: get_keys
run: |
echo 'ccache=ccache-${{ matrix.config.image }}-${{ matrix.config.compiler }}-'$(date -u +%Y-w%W) >> $GITHUB_OUTPUT
echo 'ccache=ccache-${{ matrix.config.os }}-${{ matrix.config.compiler }}-'$(date -u +%Y-w%W) >> $GITHUB_OUTPUT
echo 'logs=meson-logs-${{ join(matrix.config.*, '-') }}' | tr -d ':' >> $GITHUB_OUTPUT
echo 'pkgs=${{ needs.prepare-container-images.outputs.pkgs }}' >> $GITHUB_OUTPUT
- name: Retrieve image cache
id: image_cache
uses: actions/cache@v4
with:
path: ~/.image
key: ${{ needs.prepare-container-images.outputs.image }}
key: ${{ matrix.config.os }}
- name: Fail if no image (not supposed to happen)
if: steps.image_cache.outputs.cache-hit != 'true'
run: |
echo 'Image ${{ matrix.config.image }} is not cached.'
echo 'Image ${{ matrix.config.os }} is not cached.'
false
- name: Retrieve ccache cache
uses: actions/cache@v4
Expand All @@ -258,7 +263,7 @@ jobs:
echo STDATOMIC=false >> ~/env
- name: Load the cached image
run: |
docker load -i ~/.image/${{ matrix.config.image }}.tar
docker load -i ~/.image/${{ matrix.config.os }}.tar
docker run -d -i --rm --name dpdk \
--mount type=bind,src=$HOME/.ccache,dst=/root/.ccache \
--mount type=bind,src=$(pwd),dst=/root/dpdk \
Expand All @@ -269,11 +274,7 @@ jobs:
- name: Update
run: docker exec -i dpdk dnf update -y || true
- name: Install packages
run: docker exec -i dpdk dnf install -y ccache intel-ipsec-mb-devel
isa-l-devel jansson-devel libarchive-devel libatomic libbsd-devel
libbpf-devel libfdt-devel libpcap-devel libxdp-devel ninja-build
numactl-devel openssl-devel python3-pip python3-pyelftools
python3-setuptools python3-wheel rdma-core-devel zlib-devel
run: docker exec -i dpdk dnf install -y ${{ steps.get_keys.outputs.pkgs }}
${{ matrix.config.compiler }}
- name: Run setup
run: docker exec -i dpdk .ci/linux-setup.sh
Expand Down

0 comments on commit 1aa3009

Please sign in to comment.