Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ACR, Workflow UX, gh act, azure batch automation #43

Merged
merged 66 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
5892d23
Changes for CFA Azure ACR
jkislin Sep 18, 2024
96c64c9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 18, 2024
db86b6c
added to news.md
jkislin Sep 18, 2024
444b423
testing image on jk branch
jkislin Sep 20, 2024
5cfe5d3
update workflow name; resubmit job
jkislin Sep 20, 2024
4023f65
change runs-on to new cdcgov runner
jkislin Sep 20, 2024
4284511
removed unworking cache check
jkislin Sep 20, 2024
5c4ec10
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 20, 2024
9777717
azure batch scaffolding (maybe not necessary here)
jkislin Sep 21, 2024
5e351a9
Merge branch 'jk-azure-readiness' of https://github.com/CDCgov/cfa-ep…
jkislin Sep 21, 2024
b2e279f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 21, 2024
e955773
another attempt at cacheing and simplification; splitting the buiild/…
jkislin Sep 25, 2024
f4de2a6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 25, 2024
604069f
better github actions ux via build names
jkislin Sep 25, 2024
8403153
organized workflows for contributor/tester ux
jkislin Sep 25, 2024
5916318
removed cacheing and made names easier to read
jkislin Sep 25, 2024
e5071a7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 25, 2024
bfc8eed
comprehensive workflow renaming for ux/trackability
jkislin Sep 25, 2024
8a43469
Merge branch 'jk-azure-readiness' of https://github.com/CDCgov/cfa-ep…
jkislin Sep 25, 2024
21118f0
Merge branch 'main' of https://github.com/CDCgov/cfa-epinow2-pipeline…
jkislin Sep 25, 2024
4f9dbad
Explicit date casting in queries
zsusswein Sep 25, 2024
6745c57
Bump NEWS
zsusswein Sep 25, 2024
434b2e9
Merge branch 'zs-duckdb-update-bugfix' of https://github.com/CDCgov/c…
jkislin Sep 25, 2024
915fa76
pipeline with batch code - not yet working
jkislin Sep 25, 2024
285c8ae
Merge branch 'main' into jk-azure-readiness
jkislin Sep 25, 2024
1961bc2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 25, 2024
cd9b198
commenting out the job01 dependencies build to claw us back some test…
jkislin Sep 25, 2024
1161903
Merge branch 'jk-azure-readiness' of https://github.com/CDCgov/cfa-ep…
jkislin Sep 25, 2024
718d372
nektos gh-act tests and pool creation code
jkislin Sep 26, 2024
929fdff
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 26, 2024
9ad0060
fix some env variables for auto scale formula
jkislin Sep 26, 2024
52748bd
Merge branch 'jk-azure-readiness' of https://github.com/CDCgov/cfa-ep…
jkislin Sep 26, 2024
73efd5a
more cowbell
jkislin Sep 26, 2024
4aa8bdc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 26, 2024
d672938
fix needs issue
jkislin Sep 26, 2024
b4c21c1
Merge branch 'jk-azure-readiness' of https://github.com/CDCgov/cfa-ep…
jkislin Sep 26, 2024
ee0e5e9
we need quotes around var names"
jkislin Sep 26, 2024
21c70ca
autoscale formula as cat'd variable
jkislin Sep 26, 2024
f71a157
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 26, 2024
a0c3399
newline syntax fix for bash batch cli code
jkislin Sep 26, 2024
ba43234
Merge branch 'jk-azure-readiness' of https://github.com/CDCgov/cfa-ep…
jkislin Sep 26, 2024
62fb416
fixed endpoint uri
jkislin Sep 26, 2024
73360c7
autoscale enablement?;
jkislin Sep 26, 2024
914395b
autoscale as a separate step
jkislin Sep 26, 2024
2b30029
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 26, 2024
9211058
pool id var needs fixing in the last step
jkislin Sep 26, 2024
3194708
Merge branch 'jk-azure-readiness' of https://github.com/CDCgov/cfa-ep…
jkislin Sep 26, 2024
25d42c5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 26, 2024
aaf2a1a
environment variables
jkislin Sep 26, 2024
623ea45
Merge branch 'jk-azure-readiness' of https://github.com/CDCgov/cfa-ep…
jkislin Sep 26, 2024
aa7438f
quotes?
jkislin Sep 26, 2024
8c1bb0f
comments
jkislin Sep 26, 2024
dde360e
run name in quotes
jkislin Sep 26, 2024
2819567
Update .github/workflows/1-Build-Dependency-Image.yaml
jkislin Sep 27, 2024
a64e632
Update .gitignore
jkislin Sep 27, 2024
ea45737
added cron trigger and removed jk-azure-readiness push trigger
jkislin Sep 27, 2024
f82110a
documentation edits; file renames; revived "cacheing" for testing
jkislin Sep 27, 2024
ed939ad
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 27, 2024
22cc946
ubuntu image update?
jkislin Sep 27, 2024
dd1b777
Merge branch 'jk-azure-readiness' of https://github.com/CDCgov/cfa-ep…
jkislin Sep 27, 2024
f25af3e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 27, 2024
da7040c
node agent sku also...
jkislin Sep 27, 2024
203d661
Merge branch 'jk-azure-readiness' of https://github.com/CDCgov/cfa-ep…
jkislin Sep 27, 2024
3cd0126
attempting ubuntu 22 as 24 not yet supported
jkislin Sep 27, 2024
8355965
simplified commit message display in workflow gui
jkislin Sep 27, 2024
b5ebbf7
reverted to ubuntu 20. will have to investigate
jkislin Sep 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/1-Build-Dependency-Image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Build Dependencies Container Image
run-name: (1) Dependencies Image Build - ${{ github.event.head_commit.message }} - ${{ github.ref_name }}

# This GitHub Actions workflow builds a Docker image for the
# cfa-epinow2-pipeline-docker project. It consists of two jobs:
# build_image_dependencies and build_image.
#
# - The `build_image_dependencies` job carries out the first part of a
# multi-stage build. It downloads and install all the dependencies
jkislin marked this conversation as resolved.
Show resolved Hide resolved
# listed in the `DESCRIPTION` file. It uses the `Dockerfile-dependencies`
# file to build the image.
#
# The built image is then pushed to the corresponding registry.
#
# The process is cached to avoid rebuilding the image if the dependencies
# have not changed. This is by hashing the `DESCRIPTION` file and the
# `Dockerfile-dependencies` file.
#
# - The build_image job builds the final image using the `Dockerfile` file.
# It uses the image built in the previous job as a base image.
#
# During the build process, the package is installed and built. Furthermore
# the package is checked using `R CMD check` to ensure that it is working
# correctly.
#
# Once the image is built, it is pushed to the corresponding registry.

on:
push:
branches:
- main
- jk-azure-readiness # temporary
jkislin marked this conversation as resolved.
Show resolved Hide resolved
paths:
- "./Dockerfile-dependencies" # the dockerfile this workflow builds from
- "./.github/workflows/build-dependency-image.yaml" # this workflow
jkislin marked this conversation as resolved.
Show resolved Hide resolved

pull_request:
branches:
- main
paths:
- "./Dockerfile-dependencies" # the dockerfile this workflow builds from
- "./.github/workflows/build-dependency-image.yaml" # this workflow

workflow_dispatch:

env:
# Together, these form: cfaprdbatchcr.azurecr.io/cfa-epinow2-pipeline
REGISTRY: cfaprdbatchcr.azurecr.io
IMAGE_NAME: cfa-epinow2-pipeline

jobs:
Job01-build_image_dependencies:
runs-on: cfa-cdcgov # VM based runner serving CFA's cdcgov repos (as opposed to cdcent)
jkislin marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Checkout code
uses: actions/checkout@v4

# - name: Check cache
# uses: actions/cache@v3
# id: cache
# with:
# key: docker-dependencies-${{ runner.os }}-${{ hashFiles('./DESCRIPTION', './Dockerfile-dependencies') }}
# path:
# ./DESCRIPTION
jkislin marked this conversation as resolved.
Show resolved Hide resolved

- name: Login to the Container Registry
uses: docker/login-action@v3
with:
registry: "cfaprdbatchcr.azurecr.io"
username: "cfaprdbatchcr"
password: ${{ secrets.CFAPRDBATCHCR_REGISTRY_PASSWORD }}

# if: steps.cache.outputs.cache-hit != 'true'
jkislin marked this conversation as resolved.
Show resolved Hide resolved

- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: |
${{ env.REGISTRY}}/${{ env.IMAGE_NAME }}-dependencies:latest
${{ env.REGISTRY}}/${{ env.IMAGE_NAME }}-dependencies:${{ github.sha }}
file: ./Dockerfile-dependencies
140 changes: 140 additions & 0 deletions .github/workflows/2-Run-Epinow2-Pipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
name: Run Epinow2 Pipeline
run-name: (2) Pipeline - "${{ github.event.head_commit.message }}" - ${{ github.ref_name }}

# This GitHub Actions workflow builds a Docker image for the
# cfa-epinow2-pipeline-docker project. It consists of two jobs:
# build_image_dependencies and build_image.
#
# - The `build_image_dependencies` job carries out the first part of a
# multi-stage build. It downloads and install all the dependencies
# listed in the `DESCRIPTION` file. It uses the `Dockerfile-dependencies`
# file to build the image.
#
# The built image is then pushed to the corresponding registry.
#
# The process is cached to avoid rebuilding the image if the dependencies
# have not changed. This is by hashing the `DESCRIPTION` file and the
# `Dockerfile-dependencies` file.
#
# - The build_image job builds the final image using the `Dockerfile` file.
# It uses the image built in the previous job as a base image.
#
# During the build process, the package is installed and built. Furthermore
# the package is checked using `R CMD check` to ensure that it is working
# correctly.
#
# Once the image is built, it is pushed to the corresponding registry.


on:
push:
branches:
- main
- jk-azure-readiness # temporary
jkislin marked this conversation as resolved.
Show resolved Hide resolved
workflow_dispatch:

env:
# Together, these form: cfaprdbatchcr.azurecr.io/cfa-epinow2-pipeline
REGISTRY: cfaprdbatchcr.azurecr.io
IMAGE_NAME: cfa-epinow2-pipeline

jobs:

_01_build-model-image:
runs-on: cfa-cdcgov #
steps:

- name: Login to the Container Registry
uses: docker/login-action@v3
with:
registry: "cfaprdbatchcr.azurecr.io"
username: "cfaprdbatchcr"
password: ${{ secrets.CFAPRDBATCHCR_REGISTRY_PASSWORD }}

# Comment out if you want to just test the pool creation without waiting for build and push
- name: Build and push model pipeline image for Azure batch # second stage, the actual payload
id: build_and_push_model_image
uses: docker/build-push-action@v6
with:
push: true
tags: |
${{ env.REGISTRY}}/${{ env.IMAGE_NAME }}:latest
${{ env.REGISTRY}}/${{ env.IMAGE_NAME }}:${{ github.sha }}
file: ./Dockerfile # second stage Dockerfile

_02_create-batch-pool-and-submit-jobs:
runs-on: cfa-cdcgov
needs:
- _01_build-model-image

permissions:
contents: read
packages: write

steps:
- name: Checkout Repo
id: checkout_repo
uses: actions/checkout@v4

- name: Login to Azure with NNH Service Principal
id: azure_login_2
uses: azure/login@v2
with:
# managed by EDAV. Contact Amit Mantri or Jon Kislin if you have issues.
creds: ${{ secrets.EDAV_CFA_PREDICT_NNHT_SP }}


- name: Get Github Short sha
run: |
shortSHA=$(git rev-parse --short ${{ github.sha }})
echo "SHORT_SHA=$shortSHA" >> $GITHUB_ENV

- name: Create cfa-epinow2-pipeline Pool
id: create_batch_pool

# Every Azure Batch Pool parameter can simply go here,
# no python module or config toml necessary
env:
POOL_ID: "cfa-epinow2-${{ env.SHORT_SHA }}" # version the pools with the github sha
jkislin marked this conversation as resolved.
Show resolved Hide resolved
BATCH_ACCOUNT: "cfaprdba"
BATCH_ENDPOINT: "https://cfaprdba.eastus.batch.azure.com/"
VM_IMAGE_TAG: "canonical:0001-com-ubuntu-server-focal:20_04-lts"
jkislin marked this conversation as resolved.
Show resolved Hide resolved
NODE_AGENT_SKU_ID: "batch.node.ubuntu 20.04"
jkislin marked this conversation as resolved.
Show resolved Hide resolved
VM_SIZE: "standard_a4m_v2"
RESOURCE_GROUP: ${{ secrets.PRD_RESOURCE_GROUP }}


# The call to the az cli that actually generates the pool
run: |
az batch account login \
--resource-group ${{ secrets.PRD_RESOURCE_GROUP }} \
--name "${{ env.BATCH_ACCOUNT }}" \

az batch pool create \
--account-endpoint "${{ env.BATCH_ENDPOINT }}" \
--id "${{ env.POOL_ID }}" \
--image "${{ env.VM_IMAGE_TAG }}" \
--node-agent-sku-id "${{ env.NODE_AGENT_SKU_ID }}" \
--vm-size "${{ env.VM_SIZE }}" \

az batch pool autoscale enable \
--pool-id ${{ env.POOL_ID }} \
--auto-scale-formula "$(cat './batch-autoscale-formula.txt')"

# Let's get this POOL_ID var for the next step too
echo "POOL_ID=${{ env.POOL_ID}}" >> $GITHUB_ENV

# - name: legacy_test
# run: |
# az batch pool create --json-file ./cfa-epinow2-batch-pool-config.json


# - name: Submit azure batch job
# id: submit_batch_job
# env:
# POOL_ID: "$POOL_ID"
# BATCH_JOB_ID: "cfa-epinow2-pipeline-job-${{ env.SHORT_SHA }}"
# run: |
# az batch job create \
# --pool-id "${{ env.POOL_ID }}" \
# --id "${{ env.BATCH_JOB_ID }}"
jkislin marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# All PRs into main MUST be deliberately labelled in the NEWS.md with a succint but informative entry
# describing the changes made - this workflow checks to make sure that this has been done.

name: Check NEWS.md Update
run-name: (3) Check News.md for Compliance - ${{ github.event.head_commit.message }} - ${{ github.ref_name }}

on:
pull_request:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help

name: R-CMD-check
run-name: (4) R-CMD-check - ${{ github.event.head_commit.message }} - ${{ github.ref_name }}

on:
pull_request:
branches: [main]
push:
branches:
- main

name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: Git Checks
name: Block Fix-up (Git Check)
run-name: (5) Block Fix-up / Git Check - ${{ github.event.head_commit.message }} - ${{ github.ref_name }}


on: [pull_request]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
workflow_dispatch:

name: pkgdown
run-name: (6) pkgdown - ${{ github.event.head_commit.message }} - ${{ github.ref_name }}

jobs:
pkgdown:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
branches: [main]

name: test-coverage
run-name: (7) Test Coverage - ${{ github.event.head_commit.message }} - ${{ github.ref_name }}

jobs:
test-coverage:
Expand All @@ -27,14 +28,14 @@ jobs:
needs: coverage

- name: Test coverage
shell: Rscript {0}
run: |
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package"),
token = "${{ secrets.CODECOV_TOKEN }}"
)
shell: Rscript {0}

- name: Show testthat output
if: always()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ on:
types: [created]
workflow_dispatch:

name: Commands
name: PR Commands
run-name: (8) PR Commands - ${{ github.event.head_commit.message }} - ${{ github.ref_name }}


jobs:
document:
Expand Down
73 changes: 0 additions & 73 deletions .github/workflows/build-docker.yaml

This file was deleted.

9 changes: 9 additions & 0 deletions .github/workflows/gh-act/2-dry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# Requires that you have first run 'gh extension install nektos/gh-act'
# as well as having installed the docker engine and added your user to the docker group

# This checks syntax before you push to Github Actions, helping with debug hell
# To run the entire pipeline locally, see 2-full.sh

gh act -P cfa-cdcgov=... -n -W '.github/workflows/2-Run-Epinow2-Pipeline.yaml'
8 changes: 8 additions & 0 deletions .github/workflows/gh-act/2-full.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

# Requires that you have first run 'gh extension install nektos/gh-act'
# as well as having installed the docker engine and added your user to the docker group

# This runs the github actions workflow locally
jkislin marked this conversation as resolved.
Show resolved Hide resolved

gh act -P cfa-cdcgov=catthehacker/ubuntu:full-20.04 -W '.github/workflows/2-Run-Epinow2-Pipeline.yaml'
Loading
Loading