From 2f5c286809e13ceb4a442658bdb13a3757d70015 Mon Sep 17 00:00:00 2001 From: shawju <88799854+shawju@users.noreply.github.com> Date: Tue, 19 Oct 2021 13:35:27 -0400 Subject: [PATCH] feature/github-actions-integration (#32) * Testing github workflow * Updated/moved action file * Small syntax change * Please show up on PR * Quick Actions test * Quick Actions test 2 * Quick Actions test 3 * Actions Job Checkout Test * Actions Job Checkout Test * Actions Job Checkout Test * Actions Job Checkout Test * Actions Job Checkout Test * Actions Job Checkout Test * Actions Job Checkout Test * Actions Job Checkout Test * Actions Job Checkout Test * Actions Job Checkout Test * Actions Job Checkout Test * Actions Job Checkout Test * Actions Job Checkout Test * Actions Job Checkout Test * Install Task * Install precommit * Install precommit * Testing Docker build * Testing Docker build * Testing Docker build * Testing Docker build * Testing Docker build * Testing test job * Testing test job * Testing test job * Testing Docker Layer Caching * Testing Docker Layer Caching and Secure * Testing Secure * Testing Validate Stage * Testing Validate Stage * Testing Validate Stage * Testing Validate Stage * Testing Validate Stage * Testing hadolint * Testing hadolint * Testing hadolint * Testing Validate stage * Clean-up * More clean-up * Dockerfile clean-up * Dockerfile test * Checkout Action Test * Checkout Action Test * Unit Test - Final Test * Demo Time * Codefresh removal * Codefresh removal * Comment clean-up * Remove entrypoint and see what breaks * Use task to build; test w/ local tag * Run setup before task * Revert changes * Task to build with latest tag * Local tag * Testing local build with Entrypoint * Run test in same job as build * Change Test job name * Clean-up * Added a release workflow to push image to Docker Hub * Added published release to trigger events * Re-run * Added prereleased to trigger * Removed checkout phase in deliver job * Updated context * Added release edited as a trigger * Context to file * Added context and file * Trying a deeper context * Changed image to local * Sanity check * Revert image * Updated context and file * Removed context * Completely removed context * Changed file and context * Bring back checkout * Changed tags * Image update * Retry initial tags * Adding Buildx Action * Fixed image name * Rearrange maybe * Rerun * Changed tags * Try with release * Add release trigger * Removing metadata and changing tag to latest * Remove previous steps * Remove dependencies for deliver stage * Adding ghcr prefix to tag * Changed context and reverted tag * Bring back metadata and try with new context * Removing the checkout * Revert checkout and change image name * Use QEMU and remove metadata * Log in before extract * Removed buildx action and changed image * Add buildx * Buildx after login * Using all actions * Remove metadata * Try without checkout * Test wrong image * Using new image * Rearrange * Bring back checkout and context * Moved buildx * Remove tag trigger * Added debug to buildx action * Removed context * Removed buildx * Last try for tonight * Try a different action * Manual push to Docker Hub * Manual * Manual again * Manual once again * Adjusted image name * Using Docker Login Action * Added tag to push * Changed build command * Manual login * Revert to 401 status * Added buildx * Empty * Updated docker spec * Docker version * Clean-up Co-authored-by: Staton --- .github/workflows/pull-request.yml | 35 ++++++++++++++++++++++++++++++ .github/workflows/release.yml | 33 ++++++++++++++++++++++++++++ .pre-commit-config.yaml | 4 ---- spec/docker_spec.sh | 2 +- 4 files changed, 69 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/pull-request.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 00000000..c8e66bd0 --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,35 @@ +name: pull-request + +on: [pull_request] + +jobs: + validate: + runs-on: ubuntu-latest + name: Validate + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Run asdf + uses: asdf-vm/actions/install@v1 + - name: Run hadolint + uses: hadolint/hadolint-action@v1.5.0 + with: + dockerfile: ./src/docker/Dockerfile + - name: Run pre-commit + uses: pre-commit/action@v2.0.3 + + test: + runs-on: ubuntu-latest + needs: validate + name: Build Docker Image and Run Unit Tests + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Docker Layer Caching + uses: satackey/action-docker-layer-caching@v0.0.11 + - name: Setup Task + uses: arduino/setup-task@v1 + - name: Build the Docker Image + run: task build TAG=local + - name: Run Unit Tests + run: task test TAG=local diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..2b4972e3 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,33 @@ +name: release + +on: + release: + types: [published] + +jobs: + deliver: + runs-on: ubuntu-latest + name: Deliver to Docker Hub + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} + - name: Extract Metadata (tags & labels) + id: meta + uses: docker/metadata-action@v3 + with: + images: saicoss/anvil + - name: Build and Push to Dockerhub + uses: docker/build-push-action@v2 + with: + context: . + file: src/docker/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d0f7a800..1b70b238 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,7 +28,3 @@ repos: rev: v2.3.2 hooks: - id: prettier - - repo: https://github.com/jas-on/pre-commit-hadolint - rev: 1.0.1 - hooks: - - id: hadolint diff --git a/spec/docker_spec.sh b/spec/docker_spec.sh index ab698ede..02880b4a 100755 --- a/spec/docker_spec.sh +++ b/spec/docker_spec.sh @@ -2,7 +2,7 @@ Describe "printVersion()" printVersion() { - docker --version | grep "${DOCKER_VERSION}" + dnf list docker-ce | grep "${DOCKER_VERSION}" } It "validates tool is installed by checking version"