From 052e446a15542f7472272bb31ebe179a74800570 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Fri, 26 Jul 2024 14:13:16 -0400 Subject: [PATCH] Integrate with GitHub Actions (#1) Signed-off-by: Juan Cruz Viotti --- .github/workflows/main.yml | 19 +++++++++++++++++++ .github/workflows/pr.yml | 13 +++++++++++++ scripts/collections-fetch.sh | 2 +- scripts/collections-install.sh | 2 +- scripts/generate-configuration.sh | 4 ++-- scripts/no-uncommitted-changes.sh | 11 +++++++++++ 6 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/pr.yml create mode 100755 scripts/no-uncommitted-changes.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..046201e --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,19 @@ +name: Intelligence.AI SchemaHub + +on: + push: + branches: + - main + +concurrency: + group: ${{ github.workflow }}-${{ github.ref_type }} + cancel-in-progress: false + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: intelligence-ai/jsonschema@v2.6.0 + - uses: actions/checkout@v4 + - run: make + - run: ./scripts/no-uncommitted-changes.sh diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..a9203da --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,13 @@ +name: Intelligence.AI SchemaHub + +on: + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: intelligence-ai/jsonschema@v2.6.0 + - uses: actions/checkout@v4 + - run: make + - run: ./scripts/no-uncommitted-changes.sh diff --git a/scripts/collections-fetch.sh b/scripts/collections-fetch.sh index f53cc31..6515aea 100755 --- a/scripts/collections-fetch.sh +++ b/scripts/collections-fetch.sh @@ -14,7 +14,7 @@ OUTPUT="$2" echo "-- Fetching collections from $DIRECTORY into $OUTPUT" 1>&2 -find "$DIRECTORY" -name '*.json' -type f -depth 2 | while IFS= read -r collection +find "$DIRECTORY" -mindepth 2 -maxdepth 2 -name '*.json' -type f | while IFS= read -r collection do NAMESPACE="$(basename "$(dirname "$collection")")" ID="$(basename "$collection" .json)" diff --git a/scripts/collections-install.sh b/scripts/collections-install.sh index 073aa00..d3619b6 100755 --- a/scripts/collections-install.sh +++ b/scripts/collections-install.sh @@ -19,7 +19,7 @@ slugify() { echo "-- Installing collection schemas from $DIRECTORY into $OUTPUT" 1>&2 -find "$DIRECTORY" -name '*.json' -type f -depth 2 | while IFS= read -r collection +find "$DIRECTORY" -mindepth 2 -maxdepth 2 -name '*.json' -type f | while IFS= read -r collection do NAMESPACE="$(basename "$(dirname "$collection")")" ID="$(basename "$collection" .json)" diff --git a/scripts/generate-configuration.sh b/scripts/generate-configuration.sh index 4377529..b85f3a0 100755 --- a/scripts/generate-configuration.sh +++ b/scripts/generate-configuration.sh @@ -45,7 +45,7 @@ copy_string_property_if_present() { RESULT="$TMP/configuration.json" jq --raw-output --null-input '$ARGS.named' --arg url "$BASE_URL" > "$RESULT" -find "$DIRECTORY" -name '*.json' -type f -depth 2 | while IFS= read -r collection +find "$DIRECTORY" -mindepth 2 -maxdepth 2 -name '*.json' -type f | while IFS= read -r collection do NAMESPACE="$(basename "$(dirname "$collection")")" @@ -71,7 +71,7 @@ do fi done -find "$DIRECTORY" -name '*.json' -type f -depth 1 | while IFS= read -r manifest +find "$DIRECTORY" -mindepth 1 -maxdepth 1 -name '*.json' -type f | while IFS= read -r manifest do echo "-- Analyzing manifest $manifest" 1>&2 NAMESPACE="$(basename "$manifest" .json)" diff --git a/scripts/no-uncommitted-changes.sh b/scripts/no-uncommitted-changes.sh new file mode 100755 index 0000000..50664ad --- /dev/null +++ b/scripts/no-uncommitted-changes.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +set -o errexit +set -o nounset + +if [ -n "$(git status --porcelain)" ] +then + echo "ERROR: There are uncommitted changes" 1>&2 + git diff + exit 1 +fi