From 18389756a440f5834550fef24592d9a9d2ea1bab Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Wed, 20 Nov 2024 09:17:12 -0500 Subject: [PATCH 1/5] Add CI script to confirm local Docker-based test environment can run Signed-off-by: Alex Nelson --- .github/workflows/docker_compose_ci.yml | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/docker_compose_ci.yml diff --git a/.github/workflows/docker_compose_ci.yml b/.github/workflows/docker_compose_ci.yml new file mode 100644 index 00000000..336d8c96 --- /dev/null +++ b/.github/workflows/docker_compose_ci.yml @@ -0,0 +1,38 @@ +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + +name: Docker Compose CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.1' # Not needed with a .ruby-version file + - name: Confirm Docker Compose runs + run: | + docker compose up --wait + docker stop jekyll From 664c948866e3fc4807e21a471a73b6de2331907b Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Wed, 20 Nov 2024 09:40:55 -0500 Subject: [PATCH 2/5] Have deployment workflow depend on testable Docker Signed-off-by: Alex Nelson --- .github/workflows/docker_compose_ci.yml | 6 ++++ .github/workflows/jekyll.yml | 39 +++++++++++++++++++++---- 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker_compose_ci.yml b/.github/workflows/docker_compose_ci.yml index 336d8c96..15074a99 100644 --- a/.github/workflows/docker_compose_ci.yml +++ b/.github/workflows/docker_compose_ci.yml @@ -12,6 +12,12 @@ # # We would appreciate acknowledgement if the software is used. +# This workflow confirms a local-machine test scaffolding for the +# website continues to work with changes, such as to the Gemfile.lock +# file. +# On the primary branch, this workflow is a prerequisite of Jekyll +# deployment. + name: Docker Compose CI on: diff --git a/.github/workflows/jekyll.yml b/.github/workflows/jekyll.yml index dc33e70d..824e09b9 100644 --- a/.github/workflows/jekyll.yml +++ b/.github/workflows/jekyll.yml @@ -1,3 +1,17 @@ +# Portions of this file contributed by NIST are governed by the +# following statement: +# +# This software was developed at the National Institute of Standards +# and Technology by employees of the Federal Government in the course +# of their official duties. Pursuant to Title 17 Section 105 of the +# United States Code, this software is not subject to copyright +# protection within the United States. NIST assumes no responsibility +# whatsoever for its use by other parties, and makes no guarantees, +# expressed or implied, about its quality, reliability, or any other +# characteristic. +# +# We would appreciate acknowledgement if the software is used. + # This workflow uses actions that are not certified by GitHub. # They are provided by a third-party and are governed by # separate terms of service, privacy policy, and support @@ -5,14 +19,21 @@ # This file was started from the example workflow here: # https://github.com/actions/starter-workflows/blob/c9a0122a593db43660edaf37cf6cae081c2f45d9/pages/jekyll.yml +# Adaptations to depend on another workflow's successful conclusion came +# from here: +# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#running-a-workflow-based-on-the-conclusion-of-another-workflow # Sample workflow for building and deploying a Jekyll site to GitHub Pages name: Deploy Jekyll site to Pages on: - # Runs on pushes targeting the default branch - push: - branches: ["master"] + # Runs on completion of the Docker Compose CI workflow, which confirms + # the website builds in a local test scaffolding. + # The triggering workflow triggers on pushes targeting the default + # branch. + workflow_run: + workflows: [Docker Compose CI] + types: [completed] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: @@ -30,9 +51,9 @@ concurrency: cancel-in-progress: false jobs: - # Build job - build: + on-success: runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - name: Checkout uses: actions/checkout@v4 @@ -54,13 +75,19 @@ jobs: # Automatically uploads an artifact from the './_site' directory by default uses: actions/upload-pages-artifact@v3 + on-failure: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'failure' }} + steps: + - run: echo 'The triggering workflow failed' + # Deployment job deploy: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest - needs: build + needs: on-success steps: - name: Deploy to GitHub Pages id: deployment From 29bce072982585dd083f96a8f60d1bcbe2f4aeee Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Wed, 20 Nov 2024 09:55:51 -0500 Subject: [PATCH 3/5] Use `docker compose down` for teardown Suggested-by: Keith Chason Signed-off-by: Alex Nelson --- .github/workflows/docker_compose_ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker_compose_ci.yml b/.github/workflows/docker_compose_ci.yml index 15074a99..ce40aa24 100644 --- a/.github/workflows/docker_compose_ci.yml +++ b/.github/workflows/docker_compose_ci.yml @@ -41,4 +41,4 @@ jobs: - name: Confirm Docker Compose runs run: | docker compose up --wait - docker stop jekyll + docker compose down From d32deb2311362579680fb284139d1a5ae27389e8 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Wed, 20 Nov 2024 09:57:43 -0500 Subject: [PATCH 4/5] Add home page retrieval as smoke test Suggested-by: Keith Chason Signed-off-by: Alex Nelson --- .github/workflows/docker_compose_ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker_compose_ci.yml b/.github/workflows/docker_compose_ci.yml index ce40aa24..3aee586d 100644 --- a/.github/workflows/docker_compose_ci.yml +++ b/.github/workflows/docker_compose_ci.yml @@ -41,4 +41,5 @@ jobs: - name: Confirm Docker Compose runs run: | docker compose up --wait + curl http://0.0.0.0:4000 >/dev/null docker compose down From 25bb6dcd99cb028034782c6fb0836fd2e0e6c520 Mon Sep 17 00:00:00 2001 From: Alex Nelson Date: Wed, 20 Nov 2024 10:04:01 -0500 Subject: [PATCH 5/5] Add short sleep Signed-off-by: Alex Nelson --- .github/workflows/docker_compose_ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docker_compose_ci.yml b/.github/workflows/docker_compose_ci.yml index 3aee586d..848bbddc 100644 --- a/.github/workflows/docker_compose_ci.yml +++ b/.github/workflows/docker_compose_ci.yml @@ -41,5 +41,6 @@ jobs: - name: Confirm Docker Compose runs run: | docker compose up --wait + sleep 5 curl http://0.0.0.0:4000 >/dev/null docker compose down