Skip to content

Commit

Permalink
Sanitizers build on alpine
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgen committed Dec 29, 2023
1 parent c510222 commit c455a48
Show file tree
Hide file tree
Showing 4 changed files with 95 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/actions/docker-build-action/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: 'Docker Build and Push'
description: 'Builds and pushes Docker images to GitHub Container Registry'
inputs:
imageName:
description: 'Name of the image to build and push'
required: true
dockerFile:
description: 'Filepath relative to the repository root'
required: true
user:
description: 'User name used for ghcr'
required: true
password:
description: 'Password for user when logging in to ghcr'
required: true
outputs:
imageTag:
description: 'The tag of the built Docker image'
runs:
using: 'composite'
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Log in to GitHub Container Registry
shell: bash
run: docker login ghcr.io -u ${{ inputs.user }} -p ${{ inputs.password }}

- name: Pull existing Docker image
shell: bash
run: docker pull ghcr.io/${{ github.repository_owner }}/${{ inputs.imageName }} || true

- name: Build Docker image
shell: bash
run: docker build -t ghcr.io/${{ github.repository_owner }}/${{ inputs.imageName }} -f ${{ inputs.dockerFile }} .

- name: Push Docker image
shell: bash
run: docker push ghcr.io/${{ github.repository_owner }}/${{ inputs.imageName }}

- name: Set output
shell: bash
run: echo "name=imageTag::ghcr.io/${{ github.repository_owner }}/${{ inputs.imageName }}" >> $GITHUB_OUTPUT

46 changes: 46 additions & 0 deletions .github/workflows/build_alpine_sanitizers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build and Test with Alpine and Clang sanitizers

on: [push, pull_request]

jobs:
build-and-push-docker-image:
runs-on: ubuntu-latest
outputs:
imageTag: ${{ steps.docker-build.outputs.imageTag }}
steps:
- uses: actions/checkout@v2
- name: Build and Push Docker Image
id: docker-build
uses: ./.github/actions/docker-build-action
with:
imageName: json_struct_docker
dockerFile: docker/alpine-test.Dockerfile
user: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

test-address-sanitizer:
runs-on: ubuntu-latest
needs: build-and-push-docker-image
container: ${{ needs.build-and-push-docker-image.outputs.imageTag }}
steps:
- uses: actions/checkout@v2
- name: Run AddressSanitizer
run: |
echo "hello ${{ needs.build-and-push-docker-image.outputs.* }} world"
mkdir build && cd build
CXX=clang++ cmake -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined" -GNinja ..
ninja
ctest .
test-memory-sanitizer:
runs-on: ubuntu-latest
needs: build-and-push-docker-image
container: ${{ needs.build-and-push-docker-image.outputs.imageTag }}
steps:
- uses: actions/checkout@v2
- name: Run MemorySanitizer
run: |
mkdir build && cd build
CXX=clang++ cmake -DCMAKE_CXX_FLAGS="-fsanitize=memory" -GNinja ..
ninja
ctest .
3 changes: 3 additions & 0 deletions build_asan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CXX=clang++ cmake -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined" -GNinja ..
CXX=clang++ cmake -DCMAKE_CXX_FLAGS="-fsanitize=memory" -GNinja ..

2 changes: 2 additions & 0 deletions docker/alpine-test.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM alpine:latest
RUN apk add vim git cmake clang ninja compiler-rt

0 comments on commit c455a48

Please sign in to comment.