Initial commit with partial progress #1
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: Test | ||
on: | ||
pull_request: | ||
push: | ||
branches: [main, develop] | ||
tags: ['*'] | ||
workflow_dispatch: | ||
env: | ||
REGISTRY: ghcr.io | ||
BASE_IMG_REPO: ubuntu | ||
BASE_IMG_TAG: 22.04 | ||
NARG: 2 | ||
jobs: | ||
test_docker: | ||
runs-on: ubuntu-latest | ||
env: | ||
TAG: gha-test | ||
INT_TAG: gha-int-test | ||
# This job runs for all events that trigger this workflow | ||
steps: | ||
- name: Concatenate env variables | ||
run: | | ||
echo "PSYLLID_TAG=${{ env.REGISTRY }}/${{ github.repository }}:${{ env.TAG }}" >> $GITHUB_ENV | ||
# echo "PSYLLID_INT_TAG=${{ env.REGISTRY }}/${{ github.repository }}:${{ env.INT_TAG }}" >> $GITHUB_ENV | ||
- name: Checkout the repo | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: recursive | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
id: setup_buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
driver: docker | ||
- name: Build | ||
id: build | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: false | ||
load: true | ||
build-args: | | ||
base_image=${{ env.BASE_IMG_REPO }} | ||
base_tag=${{ env.BASE_IMG_TAG }} | ||
psyllid_tag=${{ env.TAG }} | ||
build_type=Debug | ||
enable_testing=TRUE | ||
narg=${{ env.NARG }} | ||
platforms: linux/amd64 | ||
tags: ${{ env.PSYLLID_TAG }} | ||
# - name: Build Integration Tests | ||
# id: build_int_tests | ||
# uses: docker/build-push-action@v5 | ||
# with: | ||
# context: ./testing/integration | ||
# push: false | ||
# load: true | ||
# build-args: | | ||
# img_user=${{ env.REGISTRY }}/driplineorg | ||
# img_repo=dripline-cpp | ||
# img_tag=${{ env.TAG }} | ||
# platforms: linux/amd64 | ||
# tags: ${{ env.DL_CPP_INT_TAG }} | ||
# - name: Unit Tests | ||
# run: | | ||
# docker run --rm ${{ env.PSYLLID_INT_TAG }} bash -c " | ||
# cd /usr/local/build/testing | ||
# ./run_tests" | ||
# - name: Integration Tests | ||
# run: | | ||
# cd testing/integration | ||
# ./do-testing.sh ${{ env.INT_TAG }} | ||
# For debugging | ||
# - name: Setup tmate session | ||
# if: ${{ ! success() }} | ||
# uses: mxschmitt/action-tmate@v3 | ||
jobs: | ||
docker-build-and-publish: | ||
name: Build and push the docker images | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
build: [Dev, Prod] | ||
include: | ||
- build: Dev | ||
tag-suffix: '-dev' | ||
build-type: Debug | ||
- build: Prod | ||
tag-suffix: '' | ||
build-type: Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
# Need to avoid a shallow clone (fetch-depth=1) so that the lookup of the tag works | ||
fetch-depth: 0 | ||
- name: Docker meta | ||
id: docker_meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ github.repository }} | ||
flavor: | | ||
latest=auto | ||
suffix=${{ matrix.tag-suffix }},onlatest=true | ||
tags: | | ||
type=semver,pattern={{raw}} | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} | ||
- name: Get previous tag | ||
uses: "WyriHaximus/github-action-get-previous-tag@v1" | ||
id: tag_name | ||
with: | ||
fallback: beta | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
- name: Set up Docker Buildx | ||
id: setup_buildx | ||
uses: docker/setup-buildx-action@v2 | ||
with: | ||
buildkitd-flags: --debug | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build | ||
id: build | ||
uses: docker/build-push-action@v3 | ||
with: | ||
context: . | ||
file: Dockerfile | ||
push: ${{ github.event_name == 'push' && ( contains(github.ref, 'refs/tags/') || github.ref == 'refs/heads/develop' ) }} | ||
build-args: | | ||
base_image=${{ env.BASE_IMG_REPO }} | ||
base_tag=${{ env.BASE_IMG_TAG }} | ||
psyllid_tag=${{ steps.tag_name.outputs.tag }} | ||
build_type=${{ matrix.build-type }} | ||
narg=${{ env.NARG }} | ||
tags: ${{ steps.docker_meta.outputs.tags }} | ||
platforms: linux/amd64 | ||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }} |