Skip to content

Commit

Permalink
feat: clone sanitychecks from plugin repository
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Jan 22, 2025
1 parent f460fd9 commit 1d770a2
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
81 changes: 81 additions & 0 deletions .github/workflows/sanity-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: Gather Sanity Checks

on:
push:
branches:
- feat/clone
workflow_dispatch: {}
schedule:
- cron: "0 20 * * *"

jobs:
gather:
name: Gather Sanity Checks
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main

- name: Get all sanity check from remote repository
env:
GH_TOKEN: ${{ github.token }}
run: |
DESTINATION_PATH=src/test/resources/sanity-checks/
REPOSITORIES=$(gh repo list kestra-io -L 1000 --json name | jq -r .[].name | sort | grep "^plugin-")
mkdir -p /tmp/repositories /tmp/results
cd /tmp/repositories
for REPOSITORY in $REPOSITORIES
do
git clone --filter=blob:none --sparse https://$GH_TOKEN:@github.com/kestra-io/$REPOSITORY.git
cd $REPOSITORY
git sparse-checkout init --cone
git sparse-checkout add $DESTINATION_PATH
if test -d $DESTINATION_PATH; then
COUNT=$(find $DESTINATION_PATH -type f | wc -l)
else
COUNT=0
fi
if [ "$COUNT" -gt "0" ]; then
mkdir -p ../../results/$REPOSITORY
cp -R $DESTINATION_PATH* ../../results/$REPOSITORY
echo -e "\x1B[32m-> $REPOSITORY - $COUNT found \x1B[0m"
else
echo -e "\x1B[31m-> $REPOSITORY - No sanity check found \x1B[0m"
fi
cd ..
rm -rf $REPOSITORY
done
rm -rf plugin-*
- name: Prepare the commit
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir -p sanitychecks/plugins
rm -rf sanitychecks/plugins
cp -R /tmp/results/ sanitychecks/plugins
git add *
- name: Check for changes and commit
run: |
if git diff --cached --quiet; then
echo -e "\x1B[32m-> No changes to commit. Exiting with success. \x1B[0m"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -m "chore: add sanity check from plugin repository"
git push origin main
echo -e "\x1B[32m-> Pushing to main. \x1B[0m"
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# Common
**/.env
Thumbs.db
.DS_Store
.gradle
build/
target/
out/
.idea
.vscode
*.iml
*.ipr
*.iws
.project
.settings
.classpath
.attach*

# Custom
.wip
*.py
Empty file added sanitychecks/.gitkeep
Empty file.

0 comments on commit 1d770a2

Please sign in to comment.