Skip to content

Commit

Permalink
feat: add bats test
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijie-yang committed Sep 10, 2024
1 parent 8e8da80 commit df28bae
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
7 changes: 4 additions & 3 deletions .github/actions/validate-actor/validate-actor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ image_path=$4
echo "github.actor: ${actor}"
echo "admin-only: ${admin_only}"
if [[ ${admin_only} == true ]]; then
exit_status=0
echo "Expanding team mentions in the CODEOWNERS file"
cp ${workspace}/CODEOWNERS ${workspace}/CODEOWNERS.bak
teams=$(grep -oE '@[[:alnum:]_.-]+\/[[:alnum:]_.-]+' ${workspace}/CODEOWNERS || true | sort | uniq)
Expand All @@ -26,10 +27,10 @@ if [[ ${admin_only} == true ]]; then
echo "The workflow is triggered by ${actor} as a maintainer of the image ${image_path}"
else
echo "The workflow is triggered by a user neither as a code owner nor a maintainer of the image ${image_path}"
exit 1
exit_status=1
fi
mv ${workspace}/CODEOWNERS.bak ${workspace}/CODEOWNERS
exit ${exit_status}
else
echo "The workflow is not restricted to non-code-owner or non-maintainer users"
fi

mv ${workspace}/CODEOWNERS.bak ${workspace}/CODEOWNERS
20 changes: 20 additions & 0 deletions .github/workflows/_Test-OCI-Factory.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,26 @@ jobs:
path: ${{ env.PYTEST_RESULT_PATH }}
if-no-files-found: error

bats-test:
# Trigger bash unit tests across the repository
name: bats
runs-on: ubuntu-22.04
steps:

# Job Setup
- uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Install bats
run: |
sudo apt-get update
sudo apt-get install -y bats
- name: Run bats
run: |
find ${{ github.workspace }} -name 'test-*.bats' | xargs bats
test-workflows:
name: Trigger internal tests for mock-rock
needs: [access-check]
Expand Down

0 comments on commit df28bae

Please sign in to comment.