Skip to content

Commit 3876ec9

Browse files
authored
feat!: update gcc-10 to gcc-12 (#160)
* chore: update dependencies - Update gcc-10 to gcc-12 for host and arm-none-eabi - Update bats from 1.9.0 to 1.10.0 - update ccache from 4.8.2 to 4.8.3 - update docker-cli from 24.0.4 to 24.0.6 * chore: fix linter finding * chore: switch to gdb-multiarch * chore: update test for gdb-multiarch * chore: remove arm-none-eabi-gdb including dependencies * chore: fix linter findings * chore: commit linter automatic fixes * chore: fix linter findings * chore: more quoting to make the linter happy * chore: silence shellcheck * chore: let hadoling ignore shellcheck SC1091 Don't try to follow files: https://github.com/koalaman/shellcheck/wiki/SC1091 * chore: fix deprecation in devcontainer.json * chore: also push pr images to enable testing * chore: add cleanup for pr images * chore: cleanup all image tags for PRs * chore: fix linter findings
1 parent fcc3068 commit 3876ec9

14 files changed

Lines changed: 142 additions & 109 deletions

.devcontainer/Dockerfile

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ ARG BATS_VERSION=1.10.0
44
ARG CCACHE_VERSION=4.8.3
55
ARG CLANG_VERSION=15
66
ARG DOCKER_VERSION=24.0.6
7-
ARG GCC_VERSION=10
87
ARG MULL_VERSION=0.20.0
98
ARG INCLUDE_WHAT_YOU_USE_VERSION=0.19
109
ARG XWIN_VERSION=0.3.1
@@ -14,13 +13,11 @@ ARG DEBIAN_FRONTEND=noninteractive
1413
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
1514

1615
# Install the base system with all tool dependencies
17-
COPY .devcontainer/base/apt-requirements.json /tmp/apt-requirements-base.json
18-
COPY .devcontainer/gcc-${GCC_VERSION}/apt-requirements.json /tmp/apt-requirements-gcc.json
16+
COPY .devcontainer/apt-requirements-base.json /tmp/apt-requirements-base.json
1917
# hadolint ignore=DL3008
2018
RUN apt-get update && apt-get install -y --no-install-recommends jq \
21-
&& jq -s '.[0] * .[1]' /tmp/apt-requirements-base.json /tmp/apt-requirements-gcc.json > /tmp/apt-requirements.json \
22-
&& jq -r 'to_entries | .[] | .key + "=" + .value' /tmp/apt-requirements.json | xargs apt-get install -y --no-install-recommends \
23-
&& rm /tmp/apt-requirements* \
19+
&& jq -r 'to_entries | .[] | .key + "=" + .value' /tmp/apt-requirements-base.json | xargs apt-get install -y --no-install-recommends \
20+
&& rm /tmp/apt-requirements-base.json \
2421
&& rm -rf /var/lib/apt/lists/*
2522

2623
# Include the Cisco Umbrella PKI Root
@@ -36,9 +33,11 @@ RUN python3 -m pip --no-cache-dir install \
3633
ENV CMAKE_GENERATOR="Ninja"
3734

3835
# Install clang toolchain
39-
COPY .devcontainer/clang-${CLANG_VERSION}/apt-requirements.json /tmp/apt-requirements-clang.json
36+
COPY .devcontainer/apt-requirements-clang.json /tmp/apt-requirements-clang.json
37+
# hadolint ignore=SC1091
4038
RUN wget -qO - https://apt.llvm.org/llvm-snapshot.gpg.key | gpg --dearmor -o /usr/share/keyrings/llvm-snapshot-keyring.gpg \
41-
&& echo "deb [signed-by=/usr/share/keyrings/llvm-snapshot-keyring.gpg] http://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-${CLANG_VERSION} main" | tee /etc/apt/sources.list.d/llvm.list > /dev/null \
39+
&& UBUNTU_CODENAME=$(. /etc/os-release; echo "${UBUNTU_CODENAME/*, /}") \
40+
&& echo "deb [signed-by=/usr/share/keyrings/llvm-snapshot-keyring.gpg] http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-${CLANG_VERSION} main" | tee /etc/apt/sources.list.d/llvm.list > /dev/null \
4241
&& apt-get update \
4342
&& jq -r 'to_entries | .[] | .key + "=" + .value' /tmp/apt-requirements-clang.json | xargs apt-get install -y --no-install-recommends \
4443
&& rm /tmp/apt-requirements* \
@@ -50,22 +49,26 @@ ENV PATH="$PATH:/usr/lib/llvm-${CLANG_VERSION}/bin"
5049
RUN apt-get update && apt-get install -y --no-install-recommends libclang-${CLANG_VERSION}-dev llvm-${CLANG_VERSION}-dev libsqlite3-dev \
5150
&& wget -qO - https://github.com/include-what-you-use/include-what-you-use/archive/refs/tags/${INCLUDE_WHAT_YOU_USE_VERSION}.tar.gz | tar xz -C /tmp \
5251
&& CC=clang-${CLANG_VERSION} CXX=clang++-${CLANG_VERSION} cmake -S /tmp/include-what-you-use-${INCLUDE_WHAT_YOU_USE_VERSION} -B /tmp/include-what-you-use-${INCLUDE_WHAT_YOU_USE_VERSION}/build \
53-
&& cmake --build /tmp/include-what-you-use-${INCLUDE_WHAT_YOU_USE_VERSION}/build \
5452
&& cmake --build /tmp/include-what-you-use-${INCLUDE_WHAT_YOU_USE_VERSION}/build --target install \
5553
&& rm -rf /tmp/include-what-you-use-${INCLUDE_WHAT_YOU_USE_VERSION} \
5654
&& git -C /tmp clone --recurse-submodules -b ${MULL_VERSION} https://github.com/mull-project/mull.git \
5755
&& CC=clang-${CLANG_VERSION} CXX=clang++-${CLANG_VERSION} cmake -S /tmp/mull -B /tmp/mull/build \
58-
&& cmake --build /tmp/mull/build \
5956
&& cmake --build /tmp/mull/build --target install \
6057
&& rm -rf /tmp/mull \
6158
&& apt-get purge -y libclang-${CLANG_VERSION}-dev llvm-${CLANG_VERSION}-dev libsqlite3-dev \
6259
&& apt-get autoremove -y \
6360
&& apt-get clean \
6461
&& rm -rf /var/lib/apt/lists/*
6562

63+
# Install ccache from source for a recent version
64+
RUN wget -qO - https://github.com/ccache/ccache/archive/refs/tags/v${CCACHE_VERSION}.tar.gz | tar xz -C /tmp \
65+
&& CC=clang-${CLANG_VERSION} CXX=clang++-${CLANG_VERSION} cmake -DCMAKE_BUILD_TYPE=Release -S /tmp/ccache-${CCACHE_VERSION} -B /tmp/ccache-${CCACHE_VERSION}/build \
66+
&& cmake --build /tmp/ccache-${CCACHE_VERSION}/build --target install \
67+
&& rm -rf /tmp/ccache-${CCACHE_VERSION}
68+
6669
# Install arm-gcc toolchain
67-
COPY .devcontainer/gcc-${GCC_VERSION}/install-arm-none-eabi.sh /tmp/install-arm-none-eabi.sh
68-
RUN /tmp/install-arm-none-eabi.sh && rm /tmp/install-arm-none-eabi.sh
70+
RUN mkdir /opt/gcc-arm-none-eabi \
71+
&& wget -qO - "https://developer.arm.com/-/media/Files/downloads/gnu/12.3.rel1/binrel/arm-gnu-toolchain-12.3.rel1-$(uname -m)-arm-none-eabi.tar.xz" | tar --exclude='*arm-none-eabi-gdb*' --exclude='share' --strip-components=1 -xJC /opt/gcc-arm-none-eabi
6972
ENV PATH="$PATH:/opt/gcc-arm-none-eabi/bin"
7073

7174
# Install docker-cli for Docker-from-Docker tools
@@ -85,16 +88,10 @@ RUN batstmp="$(mktemp -d /tmp/bats-core-${BATS_VERSION}.XXXX)" \
8588
RUN wget -qO - "https://github.com/Jake-Shadle/xwin/releases/download/${XWIN_VERSION}/xwin-${XWIN_VERSION}-$(uname -m)-unknown-linux-musl.tar.gz" | tar -xzv -C /usr/local/bin --strip-components=1 "xwin-${XWIN_VERSION}-$(uname -m)-unknown-linux-musl/xwin"
8689

8790
# Update all tool alternatives to the correct version
88-
RUN update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-${GCC_VERSION} 20 \
89-
&& update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-${GCC_VERSION} 20 \
90-
&& update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-${GCC_VERSION} 10 \
91+
RUN update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-12 20 \
92+
&& update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-12 20 \
93+
&& update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-12 10 \
9194
&& update-alternatives --install /usr/bin/iwyu iwyu /usr/local/bin/include-what-you-use 10 \
9295
&& update-alternatives --install /usr/bin/mull-runner mull-runner /usr/local/bin/mull-runner-${CLANG_VERSION} 10 \
9396
&& update-alternatives --install /usr/lib/mull-ir-frontend mull-ir-frontend /usr/local/lib/mull-ir-frontend-${CLANG_VERSION} 10 \
9497
&& update-alternatives --install /usr/bin/python python /usr/bin/python3 10
95-
96-
# Install ccache from source for a recent version
97-
RUN wget -qO - https://github.com/ccache/ccache/archive/refs/tags/v${CCACHE_VERSION}.tar.gz | tar xz -C /tmp \
98-
&& cmake -DCMAKE_BUILD_TYPE=Release -S /tmp/ccache-${CCACHE_VERSION} -B /tmp/ccache-${CCACHE_VERSION}/build \
99-
&& cmake --build /tmp/ccache-${CCACHE_VERSION}/build --target install \
100-
&& rm -rf /tmp/ccache-${CCACHE_VERSION}
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
{
22
"bzip2": "1.0.8-5build1",
33
"ca-certificates": "20230311ubuntu0.22.04.1",
4-
"gdb": "12.1-0ubuntu1~22.04",
4+
"g++-12": "12.3.0-1ubuntu1~22.04",
5+
"gdb-multiarch": "12.1-0ubuntu1~22.04",
56
"git": "1:2.34.1-1ubuntu1.10",
67
"gnupg2": "2.2.27-3ubuntu2.1",
7-
"libncurses5": "6.3-2ubuntu0.1",
8-
"libpython2.7": "2.7.18-13ubuntu1.1",
9-
"lsb-release": "11.1.0ubuntu4",
108
"ninja-build": "1.10.1-1",
119
"python3-pip": "22.0.2+dfsg-1ubuntu0.3",
1210
"unzip": "6.0-26ubuntu3.1",
1311
"wget": "1.21.2-2ubuntu1",
14-
"xsltproc": "1.1.34-4ubuntu0.22.04.1"
12+
"xsltproc": "1.1.34-4ubuntu0.22.04.1",
13+
"xz-utils": "5.2.5-2ubuntu1"
1514
}
File renamed without changes.

.devcontainer/devcontainer.json

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@
1111
"mounts": [
1212
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind"
1313
],
14-
"extensions": [
15-
"jetmartin.bats",
16-
"matepek.vscode-catch2-test-adapter",
17-
"ms-vscode.cmake-tools",
18-
"ms-vscode.cpptools",
19-
"SonarSource.sonarlint-vscode"
20-
]
14+
"customizations": {
15+
"vscode": {
16+
"extensions": [
17+
"jetmartin.bats",
18+
"matepek.vscode-catch2-test-adapter",
19+
"ms-vscode.cmake-tools",
20+
"ms-vscode.cpptools",
21+
"SonarSource.sonarlint-vscode"
22+
]
23+
}
24+
}
2125
}

.devcontainer/gcc-10/apt-requirements.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

.devcontainer/gcc-10/install-arm-none-eabi.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

.devcontainer/update-dependencies.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,13 @@ set -Eeuo pipefail
55
apt-get update
66
apt-get install jq -y
77

8-
for DIR in "$@"; do
9-
echo $DIR
10-
11-
JSON=$( cat $DIR/apt-requirements.json )
8+
for FILE in "$@"; do
9+
JSON=$( cat $FILE )
1210

1311
for PACKAGE in $( echo $JSON | jq -r 'keys | .[]' ); do
1412
VERSION=$( apt-cache policy "$PACKAGE" | grep -oP '(?<=Candidate:\s)(.+)' )
1513
JSON=$( echo $JSON | jq '.[$package] = $version' --arg package $PACKAGE --arg version $VERSION )
1614
done
1715

18-
echo $JSON | jq . > $DIR/apt-requirements.json
16+
echo $JSON | jq . > $FILE
1917
done

.github/workflows/build-push.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@ jobs:
2828
id-token: write
2929
steps:
3030
- uses: sigstore/cosign-installer@11086d25041f77fe8fe7b9ea4e48e3b9192b8f19 # v3.1.2
31-
if: github.event_name != 'pull_request'
3231
- uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
3332
id: meta
3433
with:
3534
images: ${{ env.REGISTRY }}/${{ github.repository }}
3635
# Generate Docker tags based on the following events/attributes
36+
# When modifying please update the tags in the clean up workflow as well
3737
tags: |
38-
type=schedule
3938
type=raw,value=latest,enable={{is_default_branch}}
4039
type=ref,event=branch
4140
type=ref,event=pr
@@ -46,7 +45,6 @@ jobs:
4645
- uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 # v3.0.0
4746
- uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
4847
- uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
49-
if: github.event_name != 'pull_request'
5048
with:
5149
registry: ${{ env.REGISTRY }}
5250
username: ${{ github.actor }}
@@ -56,15 +54,14 @@ jobs:
5654
with:
5755
file: .devcontainer/Dockerfile
5856
platforms: linux/amd64,linux/arm64
59-
push: ${{ github.event_name != 'pull_request' }}
57+
push: true
6058
tags: ${{ steps.meta.outputs.tags }}
6159
labels: ${{ steps.meta.outputs.labels }}
6260
sbom: true
6361
provenance: true
6462
cache-from: type=gha
6563
cache-to: type=gha,mode=max
6664
- name: Sign the published Docker image
67-
if: ${{ github.event_name != 'pull_request' }}
6865
env:
6966
COSIGN_EXPERIMENTAL: "true"
7067
# This step uses the identity token to provision an ephemeral certificate

.github/workflows/ci.yml

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
1-
---
2-
name: Continuous Integration
3-
4-
on:
5-
merge_group:
6-
pull_request:
7-
workflow_dispatch:
8-
9-
concurrency:
10-
group: ${{ github.ref }}-${{ github.workflow }}
11-
cancel-in-progress: true
12-
13-
permissions:
14-
contents: read
15-
16-
jobs:
17-
build-test:
18-
runs-on: ubuntu-latest
19-
steps:
20-
# While the docker/build-push-action works from the Git context, we still need
21-
# the checkout step for running our tests.
1+
---
2+
name: Continuous Integration
3+
4+
on:
5+
merge_group:
6+
pull_request:
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ${{ github.ref }}-${{ github.workflow }}
11+
cancel-in-progress: true
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
build-test:
18+
runs-on: ubuntu-latest
19+
steps:
20+
# While the docker/build-push-action works from the Git context, we still need
21+
# the checkout step for running our tests.
2222
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
2323
- uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
2424
- uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
25-
with:
26-
file: .devcontainer/Dockerfile
27-
load: true
28-
tags: ${{ github.repository }}:test
29-
cache-from: type=gha
30-
cache-to: type=gha,mode=max
31-
- name: Run Tests
32-
run: |
33-
set -Eeuo pipefail
34-
docker run --rm --mount type=bind,src="$(pwd)/test",dst=/ws -w /ws ${{ github.repository }}:test bats --formatter junit testsuite.bats | tee test-report.xml
35-
- uses: test-summary/action@62bc5c68de2a6a0d02039763b8c754569df99e3f # v2.1
36-
with:
37-
paths: test-report.xml
38-
show: all
25+
with:
26+
file: .devcontainer/Dockerfile
27+
load: true
28+
tags: ${{ github.repository }}:test
29+
cache-from: type=gha
30+
cache-to: type=gha,mode=max
31+
- name: Run Tests
32+
run: |
33+
set -Eeuo pipefail
34+
docker run --rm --mount type=bind,src="$(pwd)/test",dst=/ws -w /ws ${{ github.repository }}:test bats --formatter junit testsuite.bats | tee test-report.xml
35+
- uses: test-summary/action@62bc5c68de2a6a0d02039763b8c754569df99e3f # v2.1
36+
with:
37+
paths: test-report.xml
38+
show: all
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Cleanup Pull-Request Image
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
generate-tag-matrix:
12+
runs-on: ubuntu-latest
13+
outputs:
14+
tags: ${{ steps.matrix.outputs.tags }}
15+
steps:
16+
- uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
17+
id: meta
18+
with:
19+
images: ${{ env.REGISTRY }}/${{ github.repository }}
20+
# Generate Docker tags based on the following events/attributes
21+
tags: |
22+
type=raw,value=latest,enable={{is_default_branch}}
23+
type=ref,event=branch
24+
type=ref,event=pr
25+
type=semver,pattern={{version}}
26+
type=semver,pattern={{major}}.{{minor}}
27+
type=semver,pattern={{major}}
28+
type=sha
29+
- run: |
30+
TAGS="$(echo "${{ steps.meta.outputs.tags }}" | jq -c --raw-input 'split(",")')"
31+
echo "tags=${TAGS}" >> "${GITHUB_OUTPUT}"
32+
id: matrix
33+
delete-images:
34+
runs-on: ubuntu-latest
35+
permissions:
36+
packages: write
37+
needs: generate-tag-matrix
38+
strategy:
39+
matrix:
40+
tag: ${{ fromJSON(needs.generate-tag-matrix.outputs.tags) }}
41+
steps:
42+
- uses: bots-house/ghcr-delete-image-action@3827559c68cb4dcdf54d813ea9853be6d468d3a4 # v1.1.0
43+
with:
44+
owner: ${{ github.repository_owner }}
45+
name: ${{ github.event.repository.name }}
46+
token: ${{ secrets.GITHUB_TOKEN }}
47+
tag: ${{ matrix.tag }}

0 commit comments

Comments
 (0)