Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic docker image test #14

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 35 additions & 9 deletions .github/workflows/ci-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: Docker Image CI
on: push
env:
DOCKERHUB_USER: akospasztor
DOCKER_IMAGE_NAME: akospasztor/docker-gcc-arm

jobs:
build:
Expand All @@ -11,16 +12,16 @@ jobs:
os: [linux]
include:
- os: linux
runner: ubuntu-20.04
runner: ubuntu-latest
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Setup docker buildx
id: buildx
uses: docker/setup-buildx-action@v1
uses: docker/setup-buildx-action@v3
- name: Cache docker layers
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ matrix.version }}-${{ github.sha }}
Expand All @@ -29,26 +30,51 @@ jobs:
${{ runner.os }}-buildx-
- name: Docker metadata
id: docker_meta
uses: docker/metadata-action@v3
uses: docker/metadata-action@v5
with:
images: akospasztor/docker-gcc-arm
images: ${{ env.DOCKER_IMAGE_NAME }}
flavor: |
prefix=${{ matrix.version }}-${{ matrix.os }}-
latest=false
tags: |
type=raw,value=latest
type=semver,pattern={{version}}
- name: Login to dockerhub
uses: docker/login-action@v1
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PAT }}
- name: Build docker image
id: docker_build
uses: docker/build-push-action@v2
uses: docker/build-push-action@v5
with:
context: ./${{ matrix.version }}/${{ matrix.os }}
push: ${{ contains(github.ref, 'refs/tags/') }}
load: true
push: false
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
builder: ${{ steps.buildx.outputs.name }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Test docker image
run: >
docker run --rm -i --env GCC_VERSION=${{ matrix.version }}
${{ env.DOCKER_IMAGE_NAME }}:${{ steps.docker_meta.outputs.version }}
< script/test-gcc-version.sh
- name: Search for vulnerabilities with docker scout
uses: docker/scout-action@v1
with:
command: cves
image: ${{ env.DOCKER_IMAGE_NAME }}:${{ steps.docker_meta.outputs.version }}
only-severities: critical, high
only-fixed: true
summary: true
- name: Push docker image
if: ${{ contains(github.ref, 'refs/tags/') }}
uses: docker/build-push-action@v5
with:
context: ./${{ matrix.version }}/${{ matrix.os }}
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
builder: ${{ steps.buildx.outputs.name }}
Expand Down
17 changes: 17 additions & 0 deletions script/test-gcc-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

# This tiny script verifies that the installed GCC version is correct by
# comparing the installed GCC version to the version passed via an
# environmental variable.
# The script exits with 0 (OK) if the installed GCC version is correct and
# exits with 1 (error) if either the environmental variable is not set or the
# installed version does not match the value of the environmental variable.

[[ -z $GCC_VERSION ]] && exit 1

if arm-none-eabi-gcc --version | grep "$GCC_VERSION"
then
exit 0
else
exit 1
fi
Loading