From 817f40197f19b24bac1ef91058701ea797557e74 Mon Sep 17 00:00:00 2001 From: bfren Date: Fri, 23 Feb 2024 19:25:34 +0000 Subject: [PATCH] Adding new test framework --- .github/workflows/dev.yml | 33 +++++++++++++++++++++++------ .github/workflows/publish.yml | 18 ++++++++++++++++ overlay/etc/nu/scripts/tests/mod.nu | 0 pull.sh | 2 +- test.sh | 15 +++++++++++++ 5 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 overlay/etc/nu/scripts/tests/mod.nu create mode 100644 test.sh diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 7acfcfe..dd2d555 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -6,13 +6,10 @@ on: tags-ignore: ['**'] workflow_dispatch: +env: + TEST_TAG: ftps:test + jobs: - test: - runs-on: ubuntu-latest - steps: - - - name: Checkout code - uses: actions/checkout@v4 build: runs-on: ubuntu-latest steps: @@ -41,6 +38,28 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - + name: Build and export + id: docker_export + uses: docker/build-push-action@v5 + with: + build-args: | + BF_IMAGE=${{ env.REPOSITORY_NAME }} + BF_VERSION=${{ steps.version.outputs.contents }} + load: true + tags: ${{ env.TEST_TAG }} + - + name: Run tests + id: docker_test + run: | + docker run --entrypoint "/usr/bin/env" ${{ env.TEST_TAG }} -i nu -c "use bf test ; test" - name: Build and push id: docker_build @@ -54,6 +73,8 @@ jobs: tags: | bfren/ftps:dev bfren/ftps:${{ steps.version.outputs.contents }}-dev + ghcr.io/bfren/ftps:dev + ghcr.io/bfren/ftps:${{ steps.version.outputs.contents }}-dev - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index e28af66..1ddcdf6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -64,6 +64,13 @@ jobs: with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} + - + name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Build and push id: docker_build @@ -71,6 +78,7 @@ jobs: with: build-args: | BF_IMAGE=${{ env.REPOSITORY_NAME }} + BF_PUBLISHING=1 BF_VERSION=${{ steps.version.outputs.contents }} push: true platforms: linux/amd64,linux/arm/v7,linux/arm64 @@ -85,6 +93,16 @@ jobs: bfren/ftps:vsftpd${{ steps.vsftpd_minor.outputs.contents }}-${{ steps.version.outputs.contents }} bfren/ftps:vsftpd${{ steps.vsftpd_revision.outputs.contents }} bfren/ftps:vsftpd${{ steps.vsftpd_revision.outputs.contents }}-${{ steps.version.outputs.contents }} + ghcr.io/bfren/ftps:latest + ghcr.io/bfren/ftps:${{ steps.version_major.outputs.contents }} + ghcr.io/bfren/ftps:${{ steps.version_minor.outputs.contents }} + ghcr.io/bfren/ftps:${{ steps.version.outputs.contents }} + ghcr.io/bfren/ftps:vsftpd${{ steps.vsftpd_major.outputs.contents }} + ghcr.io/bfren/ftps:vsftpd${{ steps.vsftpd_major.outputs.contents }}-${{ steps.version.outputs.contents }} + ghcr.io/bfren/ftps:vsftpd${{ steps.vsftpd_minor.outputs.contents }} + ghcr.io/bfren/ftps:vsftpd${{ steps.vsftpd_minor.outputs.contents }}-${{ steps.version.outputs.contents }} + ghcr.io/bfren/ftps:vsftpd${{ steps.vsftpd_revision.outputs.contents }} + ghcr.io/bfren/ftps:vsftpd${{ steps.vsftpd_revision.outputs.contents }}-${{ steps.version.outputs.contents }} - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/overlay/etc/nu/scripts/tests/mod.nu b/overlay/etc/nu/scripts/tests/mod.nu new file mode 100644 index 0000000..e69de29 diff --git a/pull.sh b/pull.sh index fabcf12..108e1db 100644 --- a/pull.sh +++ b/pull.sh @@ -6,4 +6,4 @@ if [ -n "${1-}" ] ; then git checkout ${1} && git pull fi -chmod +x pull.sh run.sh +chmod +x pull.sh run.sh test.sh diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..eef1b2a --- /dev/null +++ b/test.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +IMAGE=ftps +VERSION=`cat VERSION` +TAG=${IMAGE}-test + +docker buildx build \ + --load \ + --build-arg BF_IMAGE=${IMAGE} \ + --build-arg BF_VERSION=${VERSION} \ + -f Dockerfile \ + -t ${TAG} \ + . \ + && \ + docker run --entrypoint "/usr/bin/env" ${TAG} -i nu -c "use bf test ; test"