2024 combined beginner advanced solutions #4
Workflow file for this run
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
# Builds an image that contains GeoIPS built with `pip install .[doc,lint,test]` | |
name: Build Documentation, Lint, and Test | |
env: | |
# The registry that will be used to store all images | |
# Override from repo or org level to use a different registry | |
DOCKER_REGISTRY: ghcr.io | |
# The path to the GeoIPS package in DOCLINTTEST images | |
BASE_GEOIPS_PATH: /packages/geoips | |
# Allow overriding the doclinttest image tag used for plugin packages | |
# Allows using a different version of the doc, lint, and test code | |
PLUGIN_DOCLINTTEST_TAG: doclinttest-stable | |
defaults: | |
run: | |
shell: bash | |
on: | |
# Triggers when code is pushed to "main" branch | |
# This should only happen when PRs are merged | |
push: | |
branches: | |
- main | |
# Triggers the workflow when pull request created and updated | |
pull_request: | |
# Triggers when a new release is created | |
release: | |
types: | |
- published | |
# Allows run of this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
# Set variables that should be accessible to all jobs | |
set_variables: | |
runs-on: ${{ vars.RUNNER }} | |
env: | |
CURR_REPO: ${{ github.event.repository.name }} | |
outputs: | |
# The name of the untagged docker images to be created by this workflow | |
IMAGE_NAME: ${{ steps.set_image_name.outputs.IMAGE_NAME }} | |
# The tag to use for the doclinttest images | |
DOCLINTTEST_TAG: ${{ steps.set_doclinttest_tag.outputs.DOCLINTTEST_TAG }} | |
# The image to use for doclinttest jobs | |
DOCLINTTEST_IMAGE: ${{ steps.set_doclinttest_image.outputs.DOCLINTTEST_IMAGE }} | |
# Flags for enabling/disabling various parts of the workflow | |
# Default to enabled unless overridden by a repository-level variable | |
CI_BUILD_SPHINX_HTML: ${{ steps.get_job_flags.outputs.CI_BUILD_SPHINX_HTML }} | |
CHECK_NEW_RELEASE_NOTE: ${{ steps.get_job_flags.outputs.CHECK_NEW_RELEASE_NOTE }} | |
CI_BUILD_SPHINX_PDF: ${{ steps.get_job_flags.outputs.CI_BUILD_SPHINX_PDF }} | |
CI_LINT_BANDIT: ${{ steps.get_job_flags.outputs.CI_LINT_BANDIT }} | |
CI_LINT_DOC8: ${{ steps.get_job_flags.outputs.CI_LINT_DOC8 }} | |
CI_LINT_FLAKE8: ${{ steps.get_job_flags.outputs.CI_LINT_FLAKE8 }} | |
CI_LINT_BLACK: ${{ steps.get_job_flags.outputs.CI_LINT_BLACK }} | |
CI_TEST_INTERFACES: ${{ steps.get_job_flags.outputs.CI_TEST_INTERFACES }} | |
CI_TEST_PYTEST_SHORT: ${{ steps.get_job_flags.outputs.CI_TEST_PYTEST_SHORT }} | |
steps: | |
- name: Set the image name | |
id: set_image_name | |
run: | | |
# Create an image name using the organiztion and repository names, lowercase | |
image_name=${DOCKER_REGISTRY}/${GITHUB_REPOSITORY,,} | |
echo "IMAGE_NAME=${image_name}" | |
echo "IMAGE_NAME=${image_name}" >> ${GITHUB_ENV} | |
echo "IMAGE_NAME=${image_name}" >> ${GITHUB_OUTPUT} | |
- name: Set doclinttest image tag | |
id: set_doclinttest_tag | |
run: | | |
echo "CURR_REPO: ${CURR_REPO}" | |
# If the current repository is geoips, use the image we're about to build | |
# for running tests and building docs. | |
if [[ "${CURR_REPO}" == "geoips" ]]; then | |
echo "DOCLINTTEST_TAG=doclinttest-${GITHUB_SHA}" | |
echo "DOCLINTTEST_TAG=doclinttest-${GITHUB_SHA}" >> ${GITHUB_ENV} | |
echo "DOCLINTTEST_TAG=doclinttest-${GITHUB_SHA}" >> ${GITHUB_OUTPUT} | |
else | |
echo "DOCLINTTEST_TAG=${PLUGIN_DOCLINTTEST_TAG}" | |
echo "DOCLINTTEST_TAG=${PLUGIN_DOCLINTTEST_TAG}" >> ${GITHUB_ENV} | |
echo "DOCLINTTEST_TAG=${PLUGIN_DOCLINTTEST_TAG}" >> ${GITHUB_OUTPUT} | |
fi | |
- name: Set doclinttest image | |
id: set_doclinttest_image | |
run: | | |
owner=${{ github.repository_owner }} | |
owner=${owner,,} | |
doclinttest_image_name=${DOCKER_REGISTRY}/${owner}/geoips:${DOCLINTTEST_TAG} | |
echo "DOCLINTTEST_IMAGE=${DOCKER_REGISTRY}/${owner}/geoips:${DOCLINTTEST_TAG}" | |
echo "DOCLINTTEST_IMAGE=${DOCKER_REGISTRY}/${owner}/geoips:${DOCLINTTEST_TAG}" >> ${GITHUB_ENV} | |
echo "DOCLINTTEST_IMAGE=${DOCKER_REGISTRY}/${owner}/geoips:${DOCLINTTEST_TAG}" >> ${GITHUB_OUTPUT} | |
- name: Get job flags | |
id: get_job_flags | |
run: | | |
# Define an array of flags and their corresponding secret values | |
flags=(CHECK_NEW_RELEASE_NOTE\ | |
CI_BUILD_SPHINX_HTML \ | |
CI_BUILD_SPHINX_PDF \ | |
CI_LINT_BANDIT \ | |
CI_LINT_DOC8 \ | |
CI_LINT_FLAKE8 \ | |
CI_LINT_BLACK \ | |
CI_TEST_INTERFACES \ | |
CI_TEST_PYTEST_SHORT) | |
for flag in "${flags[@]}"; do | |
# Dynamically construct the variable name and access the corresponding secret | |
case $flag in | |
CHECK_NEW_RELEASE_NOTE) val="${{ vars.CHECK_NEW_RELEASE_NOTE }}" ;; | |
CI_BUILD_SPHINX_HTML) val="${{ vars.CI_BUILD_SPHINX_HTML }}" ;; | |
CI_BUILD_SPHINX_PDF) val="${{ vars.CI_BUILD_SPHINX_PDF }}" ;; | |
CI_LINT_BANDIT) val="${{ vars.CI_LINT_BANDIT }}" ;; | |
CI_LINT_DOC8) val="${{ vars.CI_LINT_DOC8 }}" ;; | |
CI_LINT_FLAKE8) val="${{ vars.CI_LINT_FLAKE8 }}" ;; | |
CI_LINT_BLACK) val="${{ vars.CI_LINT_BLACK }}" ;; | |
CI_TEST_INTERFACES) val="${{ vars.CI_TEST_INTERFACES }}" ;; | |
CI_TEST_PYTEST_SHORT) val="${{ vars.CI_TEST_PYTEST_SHORT }}" ;; | |
esac | |
# Check if the secret value is "true" and set the environment variable and output | |
if [ "$val" == "false" ]; then | |
echo "${flag}=false" | |
echo "${flag}=false" >> $GITHUB_ENV | |
echo "${flag}=false" >> $GITHUB_OUTPUT | |
else | |
echo "${flag}=true" | |
echo "${flag}=true" >> $GITHUB_ENV | |
echo "${flag}=true" >> $GITHUB_OUTPUT | |
fi | |
done | |
print_run_flags: | |
runs-on: ${{ vars.RUNNER }} | |
needs: [set_variables] | |
steps: | |
- name: Print run flags | |
run: | | |
for var in $(echo '${{ toJson(needs.set_variables.outputs) }}' | jq -r 'keys[]'); do | |
value=$(echo '${{ toJson(needs.set_variables.outputs) }}' | jq -r --arg var "$var" '.[$var]') | |
echo "$var=$value" | |
done | |
# Build the base GeoIPS doclinttest image | |
# This image is used in all subsequent tests | |
# It is only built for the main GeoIPS package but is used by all repositories | |
# | |
# Within this image, the GeoIPS package is located in /packages/geoips and is | |
# installed using `pip install .[doc,lint,test]`. Scripts from geoips can be called | |
# from /packages/geoips. | |
build_doclinttest_image: | |
runs-on: ${{ vars.RUNNER }} | |
needs: set_variables | |
if: ${{ github.event.repository.name == 'geoips' }} | |
env: | |
IMAGE_NAME: ${{ needs.set_variables.outputs.IMAGE_NAME }} | |
BUILDCACHE_IMAGE: ${{ needs.set_variables.outputs.IMAGE_NAME }}:buildcache | |
DOCLINTTEST_IMAGE: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }} | |
# Can't write to registry without this | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup BuildX | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to the Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY }} | |
username: ${{ secrets.DOCKER_REGISTRY_USER }} | |
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | |
# This cache allows the second push below when on the main branch | |
- name: Cache Docker layers | |
uses: actions/cache@v3 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Create tags | |
run: | | |
tags="${DOCLINTTEST_IMAGE},${BUILDCACHE_IMAGE}" | |
if [[ "${GITHUB_REF}" == "refs/heads/main" ]]; then | |
tags="${tags},${IMAGE_NAME}:doclinttest-stable" | |
else | |
tags="${tags},${IMAGE_NAME}:doclinttest-latest" | |
fi | |
echo "PUSH_TAGS=${tags}" | |
echo "PUSH_TAGS=${tags}" >> $GITHUB_ENV | |
- name: Build and Push image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
target: doclinttest | |
push: true | |
tags: ${{ env.PUSH_TAGS }} | |
file: "Dockerfile" | |
cache-from: type=registry,ref=${{ env.BUILDCACHE_IMAGE }} | |
cache-to: type=registry,ref=ghcr.io/${{ env.BUILDCACHE_IMAGE }},mode=max | |
################################################# | |
# OLD Release Note NOT Added | |
################################################# | |
check_no_edits_to_rst_release_note: | |
if: > | |
always() && | |
needs.set_variables.outputs.CHECK_NEW_RELEASE_NOTE == 'true' && | |
(needs.build_doclinttest_image.result == 'success' || | |
needs.build_doclinttest_image.result == 'skipped') | |
runs-on: ${{ vars.RUNNER }} | |
needs: [build_doclinttest_image, set_variables] | |
container: | |
image: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }} | |
credentials: | |
username: ${{ secrets.DOCKER_REGISTRY_USER }} | |
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | |
env: | |
CURR_REPO: ${{ github.event.repository.name }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Configure Git safe directory | |
run: git config --global --add safe.directory $PWD | |
- name: Detect new and modified release files | |
run: | | |
#update_this_file="$(cat update_this_release_note)" | |
release_notes_dir="$PWD/docs/source/releases" #/$(dirname $update_this_file)" | |
echo "Checking for no edits to the .rst release note in dir $release_notes_dir" | |
echo "git -C . diff --name-only --diff-filter=AM remotes/origin/main -- $release_notes_dir/*.rst" | |
ret=$(git -C . diff --name-only --diff-filter=AM remotes/origin/main -- $release_notes_dir/*.rst) | |
for file in ${ret[@]}; do | |
echo " $file" | |
done | |
if [ -z "$ret" ]; then | |
echo "PASSED" | |
else | |
echo "FAILED: Release note changes detected" | |
echo "Please use brassy to enter change logs in $release_notes_dir" | |
echo "DO NOT EDIT .RST FILES DIRECTLY :))" | |
exit 1 | |
fi | |
################################################# | |
# Release Note Added | |
################################################# | |
check_new_release_note: | |
if: > | |
always() && | |
github.ref != 'refs/heads/main' && | |
needs.set_variables.outputs.CHECK_NEW_RELEASE_NOTE == 'true' && | |
(needs.build_doclinttest_image.result == 'success' || | |
needs.build_doclinttest_image.result == 'skipped') | |
runs-on: ${{ vars.RUNNER }} | |
needs: [build_doclinttest_image, set_variables] | |
container: | |
image: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }} | |
credentials: | |
username: ${{ secrets.DOCKER_REGISTRY_USER }} | |
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | |
env: | |
CURR_REPO: ${{ github.event.repository.name }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Configure Git safe directory | |
run: git config --global --add safe.directory $PWD | |
- name: Detect new and modified release files | |
run: | | |
echo "Checking for new and modified release note files in $PWD" | |
#update_this_file="$(cat update_this_release_note)" | |
release_notes_dir="$PWD/docs/source/releases/latest" #/$(dirname $update_this_file)" | |
ls $release_notes_dir | |
#current_release_note=`cat update_this_release_note` | |
echo "git -C . diff --name-only --diff-filter=AM remotes/origin/main -- $release_notes_dir/*.yaml" | |
ret=$(git -C . diff --name-only --diff-filter=AM remotes/origin/main -- $release_notes_dir/*.yaml) | |
echo "Release note files modified this PR:" | |
for file in ${ret[@]}; do | |
echo " $file" | |
done | |
if [ -z "$ret" ]; then | |
echo "FAILED: No yaml release note changes detected" | |
echo "Please use brassy to enter change logs in $release_notes_dir" | |
exit 1 | |
else | |
echo "PASSED" | |
fi | |
################################################# | |
# Documentation builds | |
################################################# | |
build_sphinx_html: | |
if: > | |
always() && | |
needs.set_variables.outputs.CI_BUILD_SPHINX_HTML == 'true' && | |
(needs.build_doclinttest_image.result == 'success' || | |
needs.build_doclinttest_image.result == 'skipped') | |
runs-on: ${{ vars.RUNNER }} | |
needs: [build_doclinttest_image, set_variables] | |
container: | |
image: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }} | |
credentials: | |
username: ${{ secrets.DOCKER_REGISTRY_USER }} | |
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | |
env: | |
CURR_REPO: ${{ github.event.repository.name }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Configure Git safe directory | |
run: git config --global --add safe.directory $PWD | |
- name: Install package | |
run: pip install . | |
- name: Build release notes from yaml files | |
id: release-note-generator | |
run: | | |
# update_this_file="$(cat $BASE_GEOIPS_PATH/update_this_release_note)" | |
# release_notes_dir="$(dirname $update_this_file)/$(basename $update_this_file .rst)" | |
release_notes_dir="$PWD/docs/source/releases/latest" #/$(dirname $update_this_file)" | |
update_this_file="$PWD/docs/source/releases/latest.rst" | |
#release_version="$(basename $update_this_file .rst)" | |
release_version="latest" | |
echo "Running brassy on directory: $release_notes_dir" | |
brassy --release-version $release_version --no-rich --output-file $update_this_file $release_notes_dir | |
echo "Done writing!" | |
echo "release_note_file=$update_this_file" >> $GITHUB_OUTPUT | |
- name: Pinken release note | |
run: pink ${{ steps.release-note-generator.outputs.release_note_file }} | |
- name: Upload release note | |
uses: actions/upload-artifact@v4 | |
with: | |
name: Release Note | |
path: ${{ steps.release-note-generator.outputs.release_note_file }} | |
if-no-files-found: error | |
- name: Run build html | |
id: build-html-docs | |
run: | | |
echo "Build html docs" | |
# Call build_docs.sh from the geoips default branch | |
# Pass in | |
# the path to the current plugin repo, | |
# the name of the current repo, | |
# "html_only" to indicate producing only html output, and | |
# the path to the docs template directory in the geoips default branch. | |
$BASE_GEOIPS_PATH/docs/build_docs.sh . $CURR_REPO html_only $BASE_GEOIPS_PATH/docs | |
ret=$? | |
if [[ "${ret##*:}" != *"0"* ]]; then | |
echo "::error::Building html docs ${ret##*:}" | |
exit 1 | |
fi | |
echo "BUILT_DOCS_PATH=$PWD/build/sphinx/html" >> $GITHUB_OUTPUT | |
- name: Upload HTML Docs | |
uses: actions/upload-artifact@v4 | |
with: | |
name: HTML Docs | |
path: ${{ steps.build-html-docs.outputs.BUILT_DOCS_PATH }} | |
if-no-files-found: error | |
# This job does not currently work because latex is not installed in the image. I think | |
# that to get this job working would only require installing texlive-base but other | |
# texlive packages might also be required. | |
# | |
# Additionally, this job is extremely slow. Building the PDF documentation is time | |
# consuming and should probably only be run on releases. Building the HTML documentation | |
# should be enough to catch any problems that crop up. | |
# | |
# build_sphinx_pdf: | |
# if: ${{ needs.set_variables.outputs.CI_DISABLE_BUILD_SPHINX_PDF == 'false' }} | |
# runs-on: ${{ vars.RUNNER }} | |
# needs: [build_doclinttest_image, set_variables] | |
# container: | |
# image: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }} | |
# credentials: | |
# username: ${{ secrets.DOCKER_REGISTRY_USER }} | |
# password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | |
# env: | |
# CURR_REPO: ${{ github.event.repository.name }} | |
# steps: | |
# - name: Checkout code | |
# uses: actions/checkout@v4 | |
# | |
# - name: Configure Git safe directory | |
# run: git config --global --add safe.directory $PWD | |
# | |
# - name: Install geoips documentation packages | |
# run: pip install -e .[doc] | |
# | |
# - name: Run build pdf | |
# run: | | |
# echo "Build pdf docs" | |
# # Call build_docs.sh from the geoips default branch | |
# # Pass in | |
# # the path to the current plugin repo, | |
# # the name of the current repo, | |
# # "pdf_only" to indicate producing only pdf output, and | |
# # the path to the docs template directory in the geoips default branch. | |
# ./docs/build_docs.sh . $CURR_REPO pdf_only ./docs | |
# ret=$? | |
# if [[ "${ret##*:}" != *"0"* ]]; then | |
# echo "::error::Building pdf docs ${ret##*:}" | |
# exit 1 | |
# fi | |
################################################# | |
# Linting | |
################################################# | |
lint_bandit: | |
if: > | |
always() && | |
needs.set_variables.outputs.CI_LINT_BANDIT == 'true' && | |
(needs.build_doclinttest_image.result == 'success' || | |
needs.build_doclinttest_image.result == 'skipped') | |
runs-on: ${{ vars.RUNNER }} | |
needs: [build_doclinttest_image, set_variables] | |
container: | |
image: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }} | |
credentials: | |
username: ${{ secrets.DOCKER_REGISTRY_USER }} | |
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Run bandit | |
shell: bash -l {0} | |
run: | | |
echo "::group::bandit_analysis" | |
echo "BANDIT analysis of code" | |
$BASE_GEOIPS_PATH/tests/utils/check_code.sh bandit ./ | |
ret=$? | |
echo "Return code: ${ret}" | |
echo "::endgroup::" | |
if [[ "${ret}" != *"0"* ]]; then | |
echo "::error::due to bandit violations, return code ${ret}" | |
exit 1 | |
fi | |
lint_doc8: | |
if: > | |
always() && | |
needs.set_variables.outputs.CI_LINT_DOC8 == 'true' && | |
(needs.build_doclinttest_image.result == 'success' || | |
needs.build_doclinttest_image.result == 'skipped') | |
runs-on: ${{ vars.RUNNER }} | |
needs: [build_doclinttest_image, set_variables] | |
container: | |
image: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }} | |
credentials: | |
username: ${{ secrets.DOCKER_REGISTRY_USER }} | |
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Run doc8 | |
shell: bash -l {0} | |
run: | | |
echo "::group::doc8_analysis" | |
if [ ! -d "./docs/source/new-docs" ]; then | |
echo "No new-docs directory found in ${CURR_REPO}" | |
exit 0 | |
fi | |
echo "Doc8 analysis of code" | |
doc8 --max-line-length=120 ./docs/source/new-docs/ | |
ret=$? | |
echo "Return code: ${ret}" | |
echo "::endgroup::" | |
if [[ "${ret}" != *"0"* ]]; then | |
echo "::error::due to doc8 violations, return code ${ret}" | |
exit 1 | |
fi | |
lint_flake8: | |
if: > | |
always() && | |
needs.set_variables.outputs.CI_LINT_FLAKE8 == 'true' && | |
(needs.build_doclinttest_image.result == 'success' || | |
needs.build_doclinttest_image.result == 'skipped') | |
runs-on: ${{ vars.RUNNER }} | |
needs: [build_doclinttest_image, set_variables] | |
container: | |
image: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }} | |
credentials: | |
username: ${{ secrets.DOCKER_REGISTRY_USER }} | |
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Run flake8 | |
shell: bash -l {0} | |
run: | | |
echo "::group::flake8_analysis" | |
echo "FLAKE8 analysis of code" | |
$BASE_GEOIPS_PATH/tests/utils/check_code.sh flake8 . | |
ret=$? | |
echo "Return code: ${ret}" | |
echo "::endgroup::" | |
if [[ "${ret}" != *"0"* ]]; then | |
echo "::error::due to flake8 violations, return code ${ret}" | |
exit 1 | |
fi | |
lint_black: | |
if: > | |
always() && | |
needs.set_variables.outputs.CI_LINT_BLACK == 'true' && | |
(needs.build_doclinttest_image.result == 'success' || | |
needs.build_doclinttest_image.result == 'skipped') | |
runs-on: ${{ vars.RUNNER }} | |
needs: [build_doclinttest_image, set_variables] | |
container: | |
image: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }} | |
credentials: | |
username: ${{ secrets.DOCKER_REGISTRY_USER }} | |
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Run code check script black | |
shell: bash -l {0} | |
run: | | |
echo "::group::black_analysis" | |
echo "BLACK analysis of code" | |
black --version | |
$BASE_GEOIPS_PATH/tests/utils/check_code.sh black ./ | |
ret=$? | |
echo "Return code: ${ret}" | |
echo "::endgroup::" | |
if [[ "${ret}" != *"0"* ]]; then | |
echo "::error::due to black violations, return code ${ret}" | |
exit 1 | |
fi | |
################################################# | |
# Code tests | |
################################################# | |
test_interfaces: | |
if: > | |
always() && | |
needs.set_variables.outputs.CI_TEST_INTERFACES == 'true' && | |
(needs.build_doclinttest_image.result == 'success' || | |
needs.build_doclinttest_image.result == 'skipped') | |
runs-on: ${{ vars.RUNNER }} | |
needs: [build_doclinttest_image, set_variables] | |
container: | |
image: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }} | |
credentials: | |
username: ${{ secrets.DOCKER_REGISTRY_USER }} | |
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Configure Git safe directory | |
run: git config --global --add safe.directory $PWD | |
- name: Pip install package | |
run: pip install -v . | |
- name: create_plugin_registries | |
run: create_plugin_registries | |
- name: Run code check script interfaces | |
run: | | |
$BASE_GEOIPS_PATH/tests/utils/check_code.sh interfaces geoips | |
ret=$? | |
echo "::group::interface_analysis" | |
echo "INTERFACES analysis of code" | |
echo "${ret}" | |
echo "::endgroup::" | |
if [[ "${ret##*:}" != *"0"* ]]; then | |
echo "::error::due to interface violations ${ret##*:}" | |
exit 1 | |
fi | |
test_pytest_short: | |
if: > | |
always() && | |
needs.set_variables.outputs.CI_TEST_PYTEST_SHORT == 'true' && | |
(needs.build_doclinttest_image.result == 'success' || | |
needs.build_doclinttest_image.result == 'skipped') | |
runs-on: ${{ vars.RUNNER }} | |
needs: [build_doclinttest_image, set_variables] | |
container: | |
image: ${{ needs.set_variables.outputs.DOCLINTTEST_IMAGE }} | |
credentials: | |
username: ${{ secrets.DOCKER_REGISTRY_USER }} | |
password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} | |
env: | |
CURR_REPO: ${{ github.event.repository.name }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Configure Git safe directory | |
run: git config --global --add safe.directory $PWD | |
- name: Pip install package | |
run: pip install -v . | |
- name: create_plugin_registries | |
run: create_plugin_registries | |
# Run unit tests for this repo if they exist | |
- name: Run pytest unit tests | |
run: | | |
echo "::group::pytest_unit_test" | |
echo "Pytest short unit tests of ${CURR_REPO}" | |
echo "which pytest" | |
which pytest | |
if [ ! -d "./tests/unit_tests" ]; then | |
echo "No unit tests found in ${CURR_REPO}" | |
exit 0 | |
fi | |
echo "pytest -q ./tests/unit_tests" | |
pytest -q ./tests/unit_tests | |
ret=$? | |
echo "Return code: ${ret}" | |
echo "::endgroup::" | |
if [[ "${ret}" != *"0"* ]]; then | |
echo "::error::due to geoips repo pytest errors, return code ${ret}" | |
exit 1 | |
fi | |
- name: Run base GeoIPS pytest unit tests | |
if: ${{ env.CURR_REPO != 'geoips' }} | |
run: | | |
echo "::group::pytest_unit_test" | |
echo "Pytest short unit tests of ${CURR_REPO} using core GeoIPS tests" | |
echo "which pytest" | |
which pytest | |
echo "pytest -q $BASE_GEOIPS_PATH/tests/unit_tests" | |
pytest -q $BASE_GEOIPS_PATH/tests/unit_tests | |
ret=$? | |
echo "Return code: ${ret}" | |
echo "::endgroup::" | |
if [[ "${ret}" != *"0"* ]]; then | |
echo "::error::due to geoips repo pytest errors, return code ${ret}" | |
exit 1 | |
fi |