2022-03-30 04:46:56 -04:00
|
|
|
name: "Charts: Lint"
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_call:
|
|
|
|
inputs:
|
|
|
|
checkoutCommit:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
chartChangesDetected:
|
|
|
|
required: true
|
|
|
|
type: string
|
2023-05-24 14:01:18 -04:00
|
|
|
modifiedFiles:
|
|
|
|
required: true
|
|
|
|
type: string
|
2022-03-30 04:46:56 -04:00
|
|
|
|
|
|
|
jobs:
|
2023-05-23 04:26:41 -04:00
|
|
|
lint-and-verify:
|
|
|
|
name: Lint Charts and Verify Dependencies
|
2023-05-05 16:36:14 -04:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
container:
|
2023-05-23 04:26:41 -04:00
|
|
|
image: tccr.io/truecharts/devcontainer:v3.1.38@sha256:2fd9355bc6791461430db87a04f5fe7b49c46bc5957bc348f1efbff4c6c7913d
|
2023-05-05 16:36:14 -04:00
|
|
|
steps:
|
2023-05-07 07:02:51 -04:00
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
|
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2023-05-23 04:26:41 -04:00
|
|
|
ref: ${{ inputs.checkoutCommit }}
|
2023-05-07 07:02:51 -04:00
|
|
|
|
|
|
|
- name: Setting repo parent dir as safe safe.directory
|
|
|
|
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
|
|
|
|
|
2023-05-23 04:26:41 -04:00
|
|
|
- name: Prep Helm
|
2023-05-05 16:36:14 -04:00
|
|
|
run: |
|
2023-05-23 04:26:41 -04:00
|
|
|
helm repo add truecharts https://charts.truecharts.org
|
|
|
|
helm repo add truecharts-deps https://deps.truecharts.org
|
|
|
|
helm repo add truecharts-library https://library-charts.truecharts.org
|
|
|
|
helm repo add truecharts-deps https://deps.truecharts.org
|
|
|
|
helm repo update
|
2022-03-30 04:46:56 -04:00
|
|
|
|
2023-05-23 04:26:41 -04:00
|
|
|
- name: Collect changes (branch-based)
|
2022-03-30 04:46:56 -04:00
|
|
|
id: list-changed
|
|
|
|
if: inputs.chartChangesDetected == 'true'
|
2022-06-07 13:41:19 -04:00
|
|
|
shell: bash
|
2022-03-30 04:46:56 -04:00
|
|
|
run: |
|
2022-04-07 09:25:14 -04:00
|
|
|
CHARTS=$(ct list-changed --config .github/ct-lint.yaml)
|
2023-05-23 04:26:41 -04:00
|
|
|
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')
|
2022-03-30 04:46:56 -04:00
|
|
|
|
2023-05-23 04:26:41 -04:00
|
|
|
echo CHANGED_CHARTS=${OUTPUT_JSON} >> "$GITHUB_OUTPUT"
|
|
|
|
if [[ $(echo ${OUTPUT_JSON} | jq --compact-output '. | length') -gt 0 ]]; then
|
|
|
|
echo "detected=true" >> "$GITHUB_OUTPUT"
|
|
|
|
fi
|
2023-05-24 14:04:47 -04:00
|
|
|
|
|
|
|
- name: Fix Fixable Pre-Commit issues
|
|
|
|
shell: bash
|
|
|
|
if: inputs.chartChangesDetected == 'true'
|
|
|
|
run: |
|
|
|
|
echo "Running pre-commit test-and-cleanup..."
|
|
|
|
pre-commit run --all ||:
|
|
|
|
# Fix sh files to always be executable
|
|
|
|
find . -name '*.sh' | xargs chmod +x
|
2022-04-05 13:30:02 -04:00
|
|
|
|
2023-05-24 14:35:19 -04:00
|
|
|
# TODO: Needs to be checked, fails currently without error
|
|
|
|
# - name: Run Pre-Commit Scan
|
|
|
|
# uses: pre-commit/action@v2.0.3
|
|
|
|
# if: steps.list-changed.outputs.detected == 'true'
|
|
|
|
# with:
|
|
|
|
# extra_args: --files ${{ inputs.modifiedFiles }}
|
2023-05-24 14:01:18 -04:00
|
|
|
|
2023-05-23 04:26:41 -04:00
|
|
|
- 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 '.[]')
|
|
|
|
for changed in ${CHANGED}; do
|
|
|
|
.github/scripts/fetch_helm_deps.sh "${changed}"
|
|
|
|
done
|
2022-04-05 13:30:02 -04:00
|
|
|
|
2023-05-23 04:26:41 -04:00
|
|
|
- name: Run Chart Linting
|
|
|
|
continue-on-error: true
|
|
|
|
id: lint
|
|
|
|
if: steps.list-changed.outputs.detected == 'true'
|
|
|
|
env:
|
|
|
|
result_file: /tmp/lint_result.txt
|
|
|
|
run: |
|
|
|
|
CHANGED=$(echo '${{ steps.list-changed.outputs.CHANGED_CHARTS }}' | jq --raw-output '.[]')
|
|
|
|
# If the github.base_ref is empty (eg it runs outside of a PR) it fails back to origin/master
|
|
|
|
.github/scripts/tc-lint.sh '${{ steps.list-changed.outputs.CHANGED_CHARTS }}' "origin/${{ github.base_ref }}"
|
2022-04-05 13:30:02 -04:00
|
|
|
|
2023-05-23 04:26:41 -04:00
|
|
|
- name: Create/Update comment
|
|
|
|
if: steps.list-changed.outputs.detected == 'true'
|
|
|
|
uses: thollander/actions-comment-pull-request@632cf9ce90574d125be56b5f3405cda41a84e2fd # v2
|
2022-04-05 13:30:02 -04:00
|
|
|
with:
|
2023-05-23 04:26:41 -04:00
|
|
|
filePath: /tmp/lint_result.txt
|
|
|
|
comment_tag: lint_results
|
|
|
|
mode: recreate
|
2022-04-05 13:30:02 -04:00
|
|
|
|
2023-05-23 04:26:41 -04:00
|
|
|
- name: Lint Result
|
|
|
|
if: steps.list-changed.outputs.detected == 'true'
|
|
|
|
shell: bash
|
2023-01-09 11:28:10 -05:00
|
|
|
run: |
|
2023-05-23 04:26:41 -04:00
|
|
|
if [ "${{ steps.lint.outcome }}" != "success" ]; then
|
|
|
|
echo "Linting failed"
|
2023-01-09 11:28:10 -05:00
|
|
|
exit 1
|
|
|
|
fi
|
2022-07-06 07:25:34 -04:00
|
|
|
|
2022-07-06 14:09:28 -04:00
|
|
|
- uses: vishnudxb/cancel-workflow@c3c77eb4383ba7d023e6614a07d94fe990501ac6 # tag=v1.2
|
2022-07-06 07:25:34 -04:00
|
|
|
if: failure()
|
|
|
|
with:
|
2022-08-08 17:57:58 -04:00
|
|
|
repo: truecharts/chart
|
2022-07-06 07:25:34 -04:00
|
|
|
workflow_id: ${{ github.run_id }}
|
|
|
|
access_token: ${{ github.token }}
|