Switch to uint8_t, some optimizations #2483
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
push: | |
branches: ["**"] | |
pull_request: | |
branches: ["**"] | |
workflow_dispatch: | |
jobs: | |
collect-solutions: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: "Checkout code" | |
uses: actions/checkout@v4 | |
- name: "Find Dockerfiles" | |
id: "solutions" | |
run: | | |
RESULTS=() | |
for DIR in $(find Prime* -type f -name Dockerfile ! -exec dirname {} \; | sort | sed -e 's|^./||'); do | |
[ -f "${DIR}/build-no" ] && continue | |
RESULTS+=( "${DIR}" ) | |
done | |
SOLUTIONS=$(printf '%s\n' "${RESULTS[@]}" | jq -R . | jq -sc .) | |
echo "solutions=${SOLUTIONS}" >> $GITHUB_OUTPUT | |
outputs: | |
solutions: ${{ steps.solutions.outputs.solutions }} | |
build: | |
env: | |
ENABLE_DOCKER_PUSH: ${{ github.repository_owner == 'PlummersSoftwareLLC' && github.ref == 'refs/heads/drag-race' }} | |
runs-on: "ubuntu-22.04" | |
needs: ["collect-solutions"] | |
strategy: | |
fail-fast: false | |
matrix: | |
solution: ${{ fromJson(needs.collect-solutions.outputs.solutions) }} | |
steps: | |
- name: "Checkout code" | |
uses: actions/checkout@v4 | |
- name: "Normalize solution name" | |
id: solution-name | |
run: | | |
NAME=$(echo "${{ matrix.solution }}" | sed -r 's/\//-/g' | tr '[:upper:]' '[:lower:]' | sed -r 's/(prime|solution_)//g') | |
echo "normalized=${NAME}" >> $GITHUB_OUTPUT | |
- name: Select arm64 build for solutions with arm64 flag file | |
id: arch-arm64 | |
run: | | |
if [[ -f "${{ matrix.solution }}/arch-arm64" ]]; then | |
echo "build=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Select amd64 build for solutions with amd64 or no flag file | |
id: arch-amd64 | |
run: | | |
if [[ -f "${{ matrix.solution }}/arch-amd64" || ! -f "${{ matrix.solution }}/arch-arm64" ]]; then | |
echo "build=true" >> $GITHUB_OUTPUT | |
fi | |
- name: Lint Dockerfile | |
uses: jbergstroem/hadolint-gh-action@v1 | |
with: | |
dockerfile: "${{ matrix.solution }}/Dockerfile" | |
output_format: tty | |
error_level: 0 | |
config_file: ./config/hadolint.yml | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
if: ${{ env.ENABLE_DOCKER_PUSH == 'true' }} | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build amd64 | |
if: steps.arch-amd64.outputs.build | |
uses: docker/build-push-action@v6 | |
with: | |
tags: primeimages/primes:${{ steps.solution-name.outputs.normalized }} | |
context: ${{ matrix.solution }} | |
platforms: linux/amd64 | |
push: ${{ env.ENABLE_DOCKER_PUSH }} | |
cache-from: type=registry,ref=primeimages/primes:${{ steps.solution-name.outputs.normalized }} | |
cache-to: type=inline | |
- name: Build arm64 | |
if: steps.arch-arm64.outputs.build | |
uses: docker/build-push-action@v6 | |
with: | |
tags: primeimages/primes:${{ steps.solution-name.outputs.normalized }} | |
context: ${{ matrix.solution }} | |
platforms: linux/arm64 | |
push: ${{ env.ENABLE_DOCKER_PUSH }} | |
cache-from: type=registry,ref=primeimages/primes:${{ steps.solution-name.outputs.normalized }} | |
cache-to: type=inline |