Skip to content

Commit

Permalink
bump ct to release v3.9.0 and make the input variables similar to eac…
Browse files Browse the repository at this point in the history
…h other

Signed-off-by: cpanato <ctadeu@gmail.com>
  • Loading branch information
cpanato committed Jul 11, 2023
1 parent 11af945 commit 7959ac5
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 35 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: test-chart-testing-action

on: [pull_request]
on:
pull_request:

jobs:
test_ct_action:
Expand All @@ -16,8 +17,8 @@ jobs:
ct version
CT_VERSION_OUTPUT=$(ct version 2>&1 /dev/null)
ACTUAL_VERSION=$(echo "$CT_VERSION_OUTPUT" | grep Version | rev | cut -d ' ' -f1 | rev)
if [[ $ACTUAL_VERSION != 'v3.8.0' ]]; then
echo 'should be v3.8.0'
if [[ $ACTUAL_VERSION != 'v3.9.0' ]]; then
echo 'should be v3.9.0'
exit 1
else
exit 0
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ A GitHub Action for installing the [helm/chart-testing](https://github.com/helm/

For more information on inputs, see the [API Documentation](https://developer.github.com/v3/repos/releases/#input)

- `version`: The chart-testing version to install (default: `v3.8.0`)
- `version`: The chart-testing version to install (default: `3.9.0`)
- `yamllint_version`: The chart-testing version to install (default: `1.27.1`)
- `yamale_version`: The chart-testing version to install (default: `3.0.4`)

Expand Down Expand Up @@ -44,15 +44,15 @@ jobs:
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.11.2
version: v3.12.1

- uses: actions/setup-python@v4
with:
python-version: '3.9'
check-latest: true

- name: Set up chart-testing
uses: helm/chart-testing-action@v2.4.0
uses: helm/chart-testing-action@v2.5.0

- name: Run chart-testing (list-changed)
id: list-changed
Expand All @@ -68,7 +68,7 @@ jobs:

- name: Create kind cluster
if: steps.list-changed.outputs.changed == 'true'
uses: helm/kind-action@v1.4.0
uses: helm/kind-action@v1.7.0

- name: Run chart-testing (install)
if: steps.list-changed.outputs.changed == 'true'
Expand Down
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ branding:
icon: anchor
inputs:
version:
description: "The chart-testing version to install (default: v3.8.0)"
description: "The chart-testing version to install (default: 3.9.0)"
required: false
default: v3.8.0
default: '3.9.0'
yamllint_version:
description: "The yamllint version to install (default: 1.27.1)"
required: false
Expand Down
52 changes: 26 additions & 26 deletions ct.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -o errexit
set -o nounset
set -o pipefail

DEFAULT_CHART_TESTING_VERSION=v3.8.0
DEFAULT_CHART_TESTING_VERSION=3.9.0
DEFAULT_YAMLLINT_VERSION=1.27.1
DEFAULT_YAMALE_VERSION=3.0.4

Expand All @@ -13,14 +13,14 @@ cat << EOF
Usage: $(basename "$0") <options>
-h, --help Display help
-v, --version The chart-testing version to use (default: $DEFAULT_CHART_TESTING_VERSION)"
-v, --version The chart-testing version to use (default: ${DEFAULT_CHART_TESTING_VERSION})"
EOF
}

main() {
local version="$DEFAULT_CHART_TESTING_VERSION"
local yamllint_version="$DEFAULT_YAMLLINT_VERSION"
local yamale_version="$DEFAULT_YAMALE_VERSION"
local version="${DEFAULT_CHART_TESTING_VERSION}"
local yamllint_version="${DEFAULT_YAMLLINT_VERSION}"
local yamale_version="${DEFAULT_YAMALE_VERSION}"

parse_command_line "$@"

Expand All @@ -36,7 +36,7 @@ parse_command_line() {
;;
-v|--version)
if [[ -n "${2:-}" ]]; then
version="$2"
version="${2#v}"
shift
else
echo "ERROR: '-v|--version' cannot be empty." >&2
Expand Down Expand Up @@ -74,8 +74,8 @@ parse_command_line() {
}

install_chart_testing() {
if [[ ! -d "$RUNNER_TOOL_CACHE" ]]; then
echo "Cache directory '$RUNNER_TOOL_CACHE' does not exist" >&2
if [[ ! -d "${RUNNER_TOOL_CACHE}" ]]; then
echo "Cache directory '${RUNNER_TOOL_CACHE}' does not exist" >&2
exit 1
fi

Expand All @@ -85,35 +85,35 @@ install_chart_testing() {
else
arch=amd64
fi
local cache_dir="$RUNNER_TOOL_CACHE/ct/$version/$arch"
local venv_dir="$cache_dir/venv"
local cache_dir="${RUNNER_TOOL_CACHE}/ct/${version}/${arch}"
local venv_dir="${cache_dir}/venv"

if [[ ! -d "$cache_dir" ]]; then
mkdir -p "$cache_dir"
if [[ ! -d "${cache_dir}" ]]; then
mkdir -p "${cache_dir}"

echo "Installing chart-testing ${version}..."
CT_CERT=https://github.com/helm/chart-testing/releases/download/$version/chart-testing_${version#v}_linux_$arch.tar.gz.pem
CT_SIG=https://github.com/helm/chart-testing/releases/download/$version/chart-testing_${version#v}_linux_$arch.tar.gz.sig
echo "Installing chart-testing v${version}..."
CT_CERT=https://github.com/helm/chart-testing/releases/download/v$version/chart-testing_${version#v}_linux_$arch.tar.gz.pem
CT_SIG=https://github.com/helm/chart-testing/releases/download/v$version/chart-testing_${version#v}_linux_$arch.tar.gz.sig

curl --retry 5 --retry-delay 1 -sSLo ct.tar.gz "https://github.com/helm/chart-testing/releases/download/$version/chart-testing_${version#v}_linux_$arch.tar.gz"
curl --retry 5 --retry-delay 1 -sSLo ct.tar.gz "https://github.com/helm/chart-testing/releases/download/v$version/chart-testing_${version#v}_linux_$arch.tar.gz"
cosign verify-blob --certificate $CT_CERT --signature $CT_SIG \
--certificate-identity "https://github.com/helm/chart-testing/.github/workflows/release.yaml@refs/heads/main" \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" ct.tar.gz
retVal=$?
if [[ "$retVal" -ne 0 ]]; then
log_error "Unable to validate chart-testing version: ${version}"
if [[ "${retVal}" -ne 0 ]]; then
log_error "Unable to validate chart-testing version: v${version}"
exit 1
fi

tar -xzf ct.tar.gz -C "$cache_dir"
tar -xzf ct.tar.gz -C "${cache_dir}"
rm -f ct.tar.gz

echo 'Creating virtual Python environment...'
python3 -m venv "$venv_dir"
python3 -m venv "${venv_dir}"

echo 'Activating virtual environment...'
# shellcheck disable=SC1090
source "$venv_dir/bin/activate"
source "${venv_dir}/bin/activate"

echo 'Installing yamllint...'
pip3 install "yamllint==${yamllint_version}"
Expand All @@ -124,16 +124,16 @@ install_chart_testing() {

# https://github.com/helm/chart-testing-action/issues/62
echo 'Adding ct directory to PATH...'
echo "$cache_dir" >> "$GITHUB_PATH"
echo "${cache_dir}" >> "${GITHUB_PATH}"

echo 'Setting CT_CONFIG_DIR...'
echo "CT_CONFIG_DIR=$cache_dir/etc" >> "$GITHUB_ENV"
echo "CT_CONFIG_DIR=${cache_dir}/etc" >> "${GITHUB_ENV}"

echo 'Configuring environment variables for virtual environment for subsequent workflow steps...'
echo "VIRTUAL_ENV=$venv_dir" >> "$GITHUB_ENV"
echo "$venv_dir/bin" >> "$GITHUB_PATH"
echo "VIRTUAL_ENV=${venv_dir}" >> "${GITHUB_ENV}"
echo "${venv_dir}/bin" >> "${GITHUB_PATH}"

"$cache_dir/ct" version
"${cache_dir}/ct" version
}

main "$@"

0 comments on commit 7959ac5

Please sign in to comment.