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

Consolidate git actions into commit-check script #10

Merged
merged 35 commits into from
May 21, 2024

Conversation

ebeaty-cisco
Copy link
Contributor

@ebeaty-cisco ebeaty-cisco commented May 10, 2024

Move commit checks to a stand alone script so that they can also be ran locally more easily during development and on commit to the internal fork of this repo.

Code changes

commit-check script contains the existing commit checks with two caveats:

  1. Helm lint is used instead of ct lint for ease of use outside of git action workflow.
  2. The version-increment check remains a separate git action.

Testing

Tests pass when they should.
Also, I have tested with failing tests to ensure that the overall commit-check script fails.

@ebeaty-cisco ebeaty-cisco changed the title cosolidated git actions Consolidated git actions May 14, 2024
@ebeaty-cisco ebeaty-cisco changed the title Consolidated git actions Consolidate git actions into commit-check script May 15, 2024
@ebeaty-cisco ebeaty-cisco marked this pull request as ready for review May 15, 2024 14:23
@@ -1,12 +1,72 @@
#!/usr/bin/env bash
# commit-check - Pre-commit checks
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this deliberate? Generally safer to pick up /usr/bin/env bash

Comment on lines 4 to 5
# correctly incermented, which is done via a seperate github action on the
# public xrd-helm repository.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# correctly incermented, which is done via a seperate github action on the
# public xrd-helm repository.
# correctly incermented, which is done via a seperate github action.

Although this is a useful comment I'd prefer to try and keep this repository agnostic of external/internal details/differences.

esac
done

if [ "$CONTAINER_TOOL" != "docker" ] && [ "$CONTAINER_TOOL" != "podman" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to just avoid this entirely? Apparently the Ubuntu images already have podman installed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, podman works fine in the GitHub action so have removed the option.

echo "Setting up python venv..."
TMP_VENV=$(mktemp -d -t venv.XXXXXX)
python3 -m venv "$TMP_VENV"
# shellcheck source=/dev/null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's this for?

It may be better to explicitly use $TMP_VENV/bin/pip regardless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It tells shellcheck to ignore the file being sourced on the next line. Have removed the source and replaced with $TMP_VENV/bin/pip

FAILURES=$((FAILURES+1))
fi

# Build container for UT and run tests using docker or podman
if [ "$CONTAINER_TOOL" == "docker" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not possible to make this just-podman, then it looks like these two branches are identical, and duplication can just be avoided by just doing e.g., $CONTAINER_TOOL run ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, as I have removed the docker option.

.github/workflows/version-increment.yml Show resolved Hide resolved
exit 1
}

while getopts ":t:" opt; do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We tend to use straight up case statements rather than getopt/getopts - getopts doesn't support long options, but getopt is not standardised.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer needed

with:
fetch-depth: 0

- uses: azure/setup-helm@v3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if this is needed, or if chart-testing-action pulls in what's needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not needed, removed.

@@ -1,36 +0,0 @@
name: release
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file shouldn't be deleted - this is for the release job (that automatically creates Helm releases on push to main, not on PR to main).

Arguably we should change this to target main branch only, for the same argument that the version-increment job is targetting main only (AIUI there's no protection against a preview branch overwriting a main branch release if we don't change this).

@ebeaty-cisco ebeaty-cisco merged commit 4dc7330 into main May 21, 2024
2 checks passed
@ebeaty-cisco ebeaty-cisco deleted the dev/ebeaty-move-commit-checks-to-script branch May 21, 2024 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants