fix(ci): find way to detect changed once (#9220)

**Description**
<!--
Please include a summary of the change and which issue is fixed. Please
also include relevant motivation and context. List any dependencies that
are required for this change.
-->
⚒️ Fixes  # <!--(issue)-->

**⚙️ Type of change**

- [ ] ⚙️ Feature/App addition
- [ ] 🪛 Bugfix
- [ ] ⚠️ Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] 🔃 Refactor of current code

**🧪 How Has This Been Tested?**
<!--
Please describe the tests that you ran to verify your changes. Provide
instructions so we can reproduce. Please also list any relevant details
for your test configuration
-->

**📃 Notes:**
<!-- Please enter any other relevant information here -->

**✔️ Checklist:**

- [ ] ⚖️ My code follows the style guidelines of this project
- [ ] 👀 I have performed a self-review of my own code
- [ ] #️⃣ I have commented my code, particularly in hard-to-understand
areas
- [ ] 📄 I have made corresponding changes to the documentation
- [ ] ⚠️ My changes generate no new warnings
- [ ] 🧪 I have added tests to this description that prove my fix is
effective or that my feature works
- [ ] ⬆️ I increased versions for any altered app according to semantic
versioning

** App addition**

If this PR is an app addition please make sure you have done the
following.

- [ ] 🪞 I have opened a PR on
[truecharts/containers](https://github.com/truecharts/containers) adding
the container to TrueCharts mirror repo.
- [ ] 🖼️ I have added an icon in the Chart's root directory called
`icon.png`

---

_Please don't blindly check all the boxes. Read them and only check
those that apply.
Those checkboxes are there for the reviewer to see what is this all
about and
the status of this PR with a quick glance._

---------

Signed-off-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
This commit is contained in:
Kjeld Schouten 2023-05-28 19:28:55 +02:00 committed by GitHub
parent 59564243ea
commit e77a030051
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 51 deletions

View File

@ -42,13 +42,15 @@ runs:
for CHARTPATH in "${PATHS[@]}"
do
IFS='/' read -r -a path_parts <<< "${CHARTPATH}"
CHARTS+=("${path_parts[1]}/${path_parts[2]}")
CHARTS+=("${path_parts[0]}/${path_parts[1]}/${path_parts[2]}")
done
# Remove duplicates
CHARTS=( `printf "%s\n" "${CHARTS[@]}" | sort -u` )
# Set output to changed charts
echo "Changed charts: ${CHARTS[*]}"
printf "::set-output name=addedOrModified::%s\n" "${CHARTS[*]}"
- name: Collect bumped charts after last tag
id: filter-bumped-charts
@ -106,11 +108,9 @@ runs:
# Remove duplicates
CHARTS=( `printf "%s\n" "${CHARTS[@]}" | sort -u` )
# Set output to changed charts
printf "::set-output name=addedOrModifiedAfterTag::%s\n" "${CHARTS[*]}"
echo "Number of detected changed charts: ${#CHARTS[@]}"
if [ ${#CHARTS[@]} -eq 0 ] || [ "${CHARTS[0]}" = " " ] || [ "${CHARTS[0]}" = "/" ]; then
if [ ${#CHARTS[@]} -eq 0 ] || [ "${CHARTS[0]}" == ' ' ] || [ "${CHARTS[0]}" == '/' ]; then
echo "No Changed Charts detected since latest tag..."
printf "::set-output name=changesDetectedAfterTag::%s\n" "false"
else
@ -120,7 +120,7 @@ runs:
# Get only the chart paths
# Set output to changed charts
echo "Changed charts: ${CHARTS[*]}"
echo "Changed charts since latest tag: ${CHARTS[*]}"
printf "::set-output name=modifiedChartsAfterTag::%s\n" "${CHARTS[*]}"
fi
popd > /dev/null

View File

@ -12,6 +12,9 @@ on:
modifiedFiles:
required: true
type: string
modifiedCharts:
required: true
type: string
jobs:
lint-and-verify:
@ -23,7 +26,13 @@ jobs:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
with:
fetch-depth: 0
fetch-depth: 1
ref: master
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
with:
fetch-depth: 1
ref: ${{ inputs.checkoutCommit }}
- name: Setting repo parent dir as safe safe.directory
@ -42,7 +51,9 @@ jobs:
if: inputs.chartChangesDetected == 'true'
shell: bash
run: |
CHARTS=$(ct list-changed --config .github/ct-lint.yaml)
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')

View File

@ -9,41 +9,11 @@ on:
chartChangesDetected:
required: true
type: string
modifiedCharts:
required: true
type: string
jobs:
unit-test:
name: Run unit tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
with:
fetch-depth: 0
ref: ${{ inputs.checkoutCommit }}
- name: Install Kubernetes tools
uses: yokawasa/action-setup-kube-tools@af4ebb1af1efd30c5bd84a2e9773355ad6362a33 # v0.9.3
with:
setup-tools: |
helmv3
helm: "3.8.0"
- name: Install Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- name: Install dependencies
env:
RUBYJQ_USE_SYSTEM_LIBRARIES: 1
run: |
sudo apt-get update
sudo apt-get install libjq-dev
bundle install
- name: Run tests
run: |
bundle exec m -r ./test/
generate-install-matrix:
name: Generate matrix for install
@ -83,7 +53,7 @@ jobs:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
with:
fetch-depth: 0
fetch-depth: 1
ref: ${{ inputs.checkoutCommit }}
- name: Set up chart-testing
@ -94,7 +64,8 @@ jobs:
if: inputs.chartChangesDetected == 'true'
run: |
EXCLUDED=$(yq eval -o=json '.excluded-charts // []' .github/ct-install.yaml)
CHARTS=$(ct list-changed --config .github/ct-install.yaml)
CHARTS=${{ inputs.modifiedCharts }}
echo "Modified Charts: ${CHARTS}"
CHARTS_JSON=$(echo "${CHARTS}" | jq -R -s -c 'split("\n")[:-1]')
OUTPUT_JSON=$(echo "{\"excluded\": ${EXCLUDED}, \"all\": ${CHARTS_JSON}}" | jq -c '.all-.excluded')
OUTPUT_JSON1=$((echo $OUTPUT_JSON | jq -r -c '.[:50]'; echo $OUTPUT_JSON | jq -r -c '.[301:350]'; echo $OUTPUT_JSON | jq -r -c '.[601:650]'; echo $OUTPUT_JSON | jq -r -c '.[901:950]'; echo $OUTPUT_JSON | jq -r -c '.[1201:1250]') | jq -s add)
@ -142,7 +113,7 @@ jobs:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
with:
fetch-depth: 0
fetch-depth: 1
ref: ${{ inputs.checkoutCommit }}
- name: Install Kubernetes tools
@ -187,7 +158,7 @@ jobs:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
with:
fetch-depth: 0
fetch-depth: 1
ref: ${{ inputs.checkoutCommit }}
- name: Install Kubernetes tools
@ -233,7 +204,7 @@ jobs:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
with:
fetch-depth: 0
fetch-depth: 1
ref: ${{ inputs.checkoutCommit }}
- name: Install Kubernetes tools
@ -278,7 +249,7 @@ jobs:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
with:
fetch-depth: 0
fetch-depth: 1
ref: ${{ inputs.checkoutCommit }}
- name: Install Kubernetes tools
@ -323,7 +294,7 @@ jobs:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
with:
fetch-depth: 0
fetch-depth: 1
ref: ${{ inputs.checkoutCommit }}
- name: Install Kubernetes tools
@ -368,7 +339,7 @@ jobs:
- name: Checkout
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3
with:
fetch-depth: 0
fetch-depth: 1
ref: ${{ inputs.checkoutCommit }}
- name: Install Kubernetes tools

View File

@ -30,8 +30,8 @@ jobs:
with:
checkoutCommit: ${{ needs.charts-changelog.outputs.commitHash }}
chartChangesDetected: ${{ needs.pr-changes.outputs.addedOrModified }}
modifiedFiles: ${{ needs.pr-metadata.outputs.addedOrModifiedFiles }}
modifiedFiles: ${{ needs.pr-changes.outputs.addedOrModifiedFiles }}
modifiedCharts: ${{ needs.pr-changes.outputs.addedOrModifiedCharts }}
charts-test:
uses: ./.github/workflows/charts-test.yaml
needs:
@ -40,6 +40,7 @@ jobs:
with:
checkoutCommit: ${{ needs.charts-changelog.outputs.commitHash }}
chartChangesDetected: ${{ needs.pr-changes.outputs.addedOrModified }}
modifiedCharts: ${{ needs.pr-changes.outputs.addedOrModifiedCharts }}
catalog-test:
uses: ./.github/workflows/catalog-test.yaml

View File

@ -22,7 +22,7 @@ sources:
- https://github.com/truecharts/charts/tree/master/charts/stable/jackett
- https://github.com/Jackett/Jackett
type: application
version: 14.0.25
version: 14.0.26
annotations:
truecharts.org/catagories: |
- media