Skip to content

Bump github/codeql-action from 2.21.5 to 2.21.9 #161

Bump github/codeql-action from 2.21.5 to 2.21.9

Bump github/codeql-action from 2.21.5 to 2.21.9 #161

Workflow file for this run

name: PR-Testing the action
on:
pull_request:
workflow_dispatch:
# declare default GITHUB_TOKEN permissions as read only.
permissions: read-all
jobs:
test-load-from-user: # test the action for the user space
name: PR - User space
runs-on: ubuntu-latest
env:
user: ${{ vars.USER }}
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
# make sure we have a new build, in case the dist folder was not updated
- name: Compile with NPM
run: |
npm ci
npm run all
# run the test
- uses: ./
name: Load available actions
with:
PAT: ${{ secrets.GITHUB_TOKEN }}
user: ${{ env.user }}
id: load-actions
# check if the result file is not empty
- name: Check if the result file is not empty
run: |
if [ ! -s "${{ steps.load-actions.outputs.actions-file-path }}" ]; then
echo "The result file is empty" | tee "$GITHUB_STEP_SUMMARY"
exit 1
fi
echo "Found [$(jq '.actions | length' "${{ steps.load-actions.outputs.actions-file-path }}")] actions in the user space of [${{ env.user }}]" | tee "$GITHUB_STEP_SUMMARY"
- name: Check if the result file has actions in it
run: |
# check if the file has actions in it
if [ "$(jq '.actions | length' "${{ steps.load-actions.outputs.actions-file-path }}")" -eq 0 ]; then
echo ":warning: The result file does not contain any actions" | tee "$GITHUB_STEP_SUMMARY"
exit 1
fi
- name: Check if the results file has duplicate actions
run: |
# check if the file has actions in it
# this is WIP, it seems like there where duplicates of the actions results since we picked up the normal repos in the forks search as well (was fixed)
echo "Actions array length = $(jq '.actions | length' "${{ steps.load-actions.outputs.actions-file-path }}")"
echo "Unique actions by name = $(jq '.actions | unique_by({name, repo}) | length' "${{ steps.load-actions.outputs.actions-file-path }}")"
if [ "$(jq '.actions | length' "${{ steps.load-actions.outputs.actions-file-path }}")" -ne "$(jq '.actions | unique_by({name, repo}) | length' "${{ steps.load-actions.outputs.actions-file-path }}")" ]; then
echo "The result file contains duplicate actions" | tee "$GITHUB_STEP_SUMMARY"
# group the actions to find the duplicates
jq '.actions | group_by({name, repo}) | map(select(length > 1))' "${{ steps.load-actions.outputs.actions-file-path }}"
exit 1
fi
# upload the second result file as an artefact
- name: Upload result file as artefact
if: always()
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: actions-user
path: ${{ steps.load-actions.outputs.actions-file-path }}
# run the test with a different filename
- uses: ./
name: Load available actions
with:
PAT: ${{ secrets.GITHUB_TOKEN }}
user: ${{ vars.USER }}
outputFilename: actions-second-run.json
id: load-actions-second-run
# check if the second result file is not empty
- name: Check if the second result file is not empty
run: |
if [ ! -s '${{ steps.load-actions-second-run.outputs.actions-file-path }}' ]; then
echo "The result file is empty" | tee "$GITHUB_STEP_SUMMARY"
exit 1
fi
# upload the second result file as an artefact
- name: Upload result file as artefact
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: actions-user
path: ${{ steps.load-actions-second-run.outputs.actions-file-path }}
# validate that the two files have different names
- name: Validate that the two files have different names
run: |
if [ ${{ steps.load-actions.outputs.actions-file-path }} == ${{ steps.load-actions-second-run.outputs.actions-file-path }} ]; then
echo ":warning: The two files have the same name, this is not good" | tee "$GITHUB_STEP_SUMMARY"
exit 1
else
echo "The two files have different names, this is good" | tee "$GITHUB_STEP_SUMMARY"
fi
test-load-from-organization-with-forks: # test the action for the organization space
needs: test-load-from-user
runs-on: ubuntu-latest
concurrency: single-run-${{ github.EVENT_NAME }}-${{ github.REF }}
name: PR - Org with forks
env:
organization: ${{ vars.ORGANIZATION }}
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
# make sure we have a new build, in case the dist folder was not updated
- name: Compile with NPM
run: |
npm ci
npm run all
# run the test
- uses: ./
name: Load available actions
with:
PAT: ${{ secrets.GITHUB_TOKEN }}
organization: ${{ env.organization }}
id: load-actions
# check if the result file is not empty
- name: Check if the result file is not empty
run: |
if [ ! -s "${{ steps.load-actions.outputs.actions-file-path }}" ]; then
echo "The result file is empty" | tee "$GITHUB_STEP_SUMMARY"
exit 1
fi
echo "Found [$(jq '.actions | length' "${{ steps.load-actions.outputs.actions-file-path }}")] actions in the organization [${{ env.organization }}]" | tee "$GITHUB_STEP_SUMMARY"
- name: Check if the result file has actions in it
run: |
# check if the file has actions in it
if [ "$(jq '.actions | length' "${{ steps.load-actions.outputs.actions-file-path }}")" -eq 0 ]; then
echo ":warning: The result file does not contain any actions" | tee "$GITHUB_STEP_SUMMARY"
exit 1
fi
- name: Upload result file as artefact
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
if: always()
with:
name: actions-organization-with-forks
path: ${{ steps.load-actions.outputs.actions-file-path }}
test-load-from-organization: # test the action for the organization space
name: PR - Org without forks
runs-on: ubuntu-latest
concurrency: single-run-${{ github.EVENT_NAME }}-${{ github.REF }}
env:
organization: actions # load from github.com/actions
if: always()
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
# make sure we have a new build, in case the dist folder was not updated
- name: Compile with NPM
run: |
npm ci
npm run all
# run the test
- uses: ./
name: Load available actions
with:
PAT: ${{ secrets.GITHUB_TOKEN }}
organization: ${{ env.organization }}
id: load-actions
# check if the result file is not empty
- name: Check if the result file is not empty
run: |
if [ ! -s '${{ steps.load-actions.outputs.actions-file-path }}' ]; then
echo "The result file is empty"
exit 1
fi
echo "Found [$(jq '.actions | length' "${{ steps.load-actions.outputs.actions-file-path }}")] actions in the organization [${{ env.organization }}]<br>Found [$(jq '.workflows| length' "${{ steps.load-actions.outputs.actions-file-path }}")] workflows in the organization [${{ env.organization }}]" | tee "$GITHUB_STEP_SUMMARY"
- name: Check if the result file has actions in it
run: |
# check if the file has actions in it
if [ "$(jq ".actions | length" "${{ steps.load-actions.outputs.actions-file-path }}")" -eq 0 ]; then
echo ":warning: The result file does not contain any actions" | tee "$GITHUB_STEP_SUMMARY"
exit 1
fi
- name: Check if the result file has workflows in it
run: |
# check if the file has workflows in it
if [ "$(jq ".workflows | length" "${{ steps.load-actions.outputs.actions-file-path }}")" -eq 0 ]; then
echo ":warning: The result file does not contain any workflows" | tee "$GITHUB_STEP_SUMMARY"
exit 1
fi
- name: Upload result file as artefact
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
with:
name: actions-organization
path: ${{ steps.load-actions.outputs.actions-file-path }}
Consolidate:
runs-on: ubuntu-latest
needs:
- test-load-from-user
- test-load-from-organization
- test-load-from-organization-with-forks
steps:
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
- run: |
ls -la
# make sure the three expected directories exists
if [ ! -d "actions-user" ]; then
echo "actions-user directory does not exist"
fi
if [ ! -d "actions-organization" ]; then
echo "actions-organization directory does not exist"
fi
if [ ! -d "actions-organization-with-forks" ]; then
echo "actions-organization-with-forks directory does not exist"
fi
# load the actions from the user
userActionsLength=$(jq -s '.[]' "./actions-user/actions.json")
organizationActionsLength=$(jq -s '.[]' "./actions-organization/actions.json")
organizationWithForksActionsLength=$(jq -s '.[]' "./actions-organization-with-forks/actions.json")
# test if the lenghts are all different
if ((userActionsLength == organizationActionsLength)); then
echo "The user actions and the organization actions are the same length, which should not be the case"
exit 1
fi
if ((organizationWithForksActionsLength == organizationActionsLength)); then
echo "The organization with forks actions and the organization actions are the same length, which should not be the case"
exit 1
fi
if ((userActionsLength == organizationWithForksActionsLength)); then
echo "The user actions and the organization with forks actions are the same length, which should not be the case"
exit 1
fi