TrueChartsClone/.github/workflows/catalog-test.yaml

100 lines
3.3 KiB
YAML

name: "SCALE: catalog-tests"
on:
workflow_call:
inputs:
checkoutCommit:
required: true
type: string
chartChangesDetected:
required: true
type: string
modifiedCharts:
required: true
type: string
jobs:
catalog-tests:
name: Test SCALE Catalog
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
name: Checkout
with:
fetch-depth: 100
ref: ${{ inputs.checkoutCommit }}
- name: Setting repo parent dir as safe safe.directory
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4
name: Checkout-validate
with:
fetch-depth: 1
repository: truecharts/catalog_validation
path: .catalog_validation
- name: install catalog_validation
shell: bash
run: |
cd .catalog_validation
pip install -r requirements.txt
pip install -U --no-cache-dir .
cd -
- name: Install go-yq
run: |
mkdir -p $HOME/.local/bin
wget https://github.com/mikefarah/yq/releases/download/v4.26.1/yq_linux_amd64 -O $HOME/.local/bin/go-yq && \
chmod +x $HOME/.local/bin/go-yq
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Collect changes (branch-based)
id: list-changed
if: inputs.chartChangesDetected == 'true'
shell: bash
run: |
CHARTS="${{ inputs.modifiedCharts }}"
echo "Modified Charts: ${CHARTS}"
EXCLUDED_JSON=$(go-yq eval -o=json '.excluded-charts // []' .github/ct-lint.yaml)
CHARTS_JSON=$(echo "${CHARTS}" | jq --raw-input '.' | jq --compact-output --slurp '.')
OUTPUT_JSON=$(echo "{\"excluded\": ${EXCLUDED_JSON}, \"all\": ${CHARTS_JSON}}" | jq --compact-output '.all-.excluded')
echo CHANGED_CHARTS=${OUTPUT_JSON} >> "$GITHUB_OUTPUT"
if [[ $(echo ${OUTPUT_JSON} | jq --compact-output '. | length') -gt 0 ]]; then
echo "detected=true" >> "$GITHUB_OUTPUT"
fi
- name: Fetch and Verify dependencies
shell: bash
if: steps.list-changed.outputs.detected == 'true'
env:
charts_path: "./"
run: |
CHANGED=$(echo '${{ steps.list-changed.outputs.CHANGED_CHARTS }}' | jq --raw-output '.[]')
./charttool deps ${CHANGED}
- name: Build Catalog
shell: bash
if: steps.list-changed.outputs.detected == 'true'
env:
charts_path: "./"
run: |
CHANGED=$(echo '${{ steps.list-changed.outputs.CHANGED_CHARTS }}' | jq --raw-output '.[]')
./charttool buildSCALE ${CHANGED}
## TODO: Only run on the existing catalog when CI or template changes are actually detected
# - name: Checkout
# uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
# with:
# repository: truecharts/catalog
# path: catalog
- name: Test Catalog
shell: bash
if: steps.list-changed.outputs.detected == 'true'
run: |
echo "Starting Catalog Validation"
python3 .catalog_validation/catalog_validation/scripts/catalog_validate.py validate --path "${PWD}/catalog" --ignore-catalog-json