Skip to content

refactor: Extract deployment file model classes to sqrl-deployment-model #1152

refactor: Extract deployment file model classes to sqrl-deployment-model

refactor: Extract deployment file model classes to sqrl-deployment-model #1152

Workflow file for this run

name: CI
on:
pull_request:
push:
branches:
- main
- 'release-*'
jobs:
check-changes:
runs-on: ubuntu-latest
outputs:
has-code: ${{ steps.filter.outputs.has-code }}
has-docs: ${{ steps.filter.outputs.has-docs }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Detect change scopes
id: filter
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE_SHA="${{ github.event.pull_request.base.sha }}"
else
BASE_SHA="${{ github.event.before }}"
fi
CHANGED=$(git diff --name-only "$BASE_SHA" "${{ github.sha }}" 2>/dev/null || echo "FORCE_BUILD")
echo "has-code=$(echo "$CHANGED" | grep -qv '^documentation/' && echo true || echo false)" >> "$GITHUB_OUTPUT"
echo "has-docs=$(echo "$CHANGED" | grep -q '^documentation/' && echo true || echo false)" >> "$GITHUB_OUTPUT"
documentation:
needs: check-changes
if: needs.check-changes.outputs.has-docs == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
submodules: false
- name: Init submodules and sparse checkout
run: |
git submodule update --init --depth 1
cd documentation/docs/stdlib-docs
git sparse-checkout init --cone
git sparse-checkout set stdlib-docs
git checkout main
git pull --ff-only origin main
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22
cache: 'npm'
cache-dependency-path: documentation/package-lock.json
- name: Install dependencies
working-directory: documentation
run: npm install
- name: Build Docusaurus site
working-directory: documentation
run: npm run build
build:
needs: check-changes
if: needs.check-changes.outputs.has-code == 'true'
runs-on: ubuntu-latest
timeout-minutes: 45
steps:
- name: Evaluate CircleCI Workflow Status
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
REPO="${{ github.repository }}"
# Use the PR head SHA if available, otherwise fallback to the push SHA
SHA="${{ github.event.pull_request.head.sha || github.sha }}"
# Define the stages we need to wait for. Add or remove contexts as needed.
CONTEXTS=(
"ci/circleci: unit-tests"
"ci/circleci: integration-tests-0-2"
"ci/circleci: integration-tests-1-2"
"ci/circleci: container-e2e-test"
"ci/circleci: build-images"
"ci/circleci: deploy"
)
echo "Waiting for CircleCI on $SHA..."
while true; do
# Fetch all statuses for the SHA. Capture errors if the API is down or returns HTML.
if ! RAW_STATUS=$(gh api "repos/$REPO/commits/$SHA/status" 2>/dev/null); then
echo "GitHub API error or unreachable. Retrying in 10s..."
sleep 10
continue
fi
# Ensure it is valid JSON
if ! echo "$RAW_STATUS" | jq empty 2>/dev/null; then
echo "GitHub API returned invalid JSON. Retrying in 10s..."
sleep 10
continue
fi
STATUSES=$(echo "$RAW_STATUS" | jq -r '.statuses // empty')
ALL_SUCCESS=true
ANY_FAILED=false
for CONTEXT in "${CONTEXTS[@]}"; do
# Use jq to extract the state for the specific context
STATE=$(echo "$STATUSES" | jq -r "map(select(.context == \"$CONTEXT\")) | .[0].state // empty")
if [[ -z "$STATE" ]] || [[ "$STATE" == "pending" ]]; then
ALL_SUCCESS=false
echo " ⏳ '$CONTEXT' is pending or not started."
elif [[ "$STATE" == "success" ]]; then
echo " ✅ '$CONTEXT' passed."
else
echo " ❌ '$CONTEXT' failed or errored (state: $STATE)."
ANY_FAILED=true
fi
done
if [[ "$ANY_FAILED" == true ]]; then
echo "One or more CircleCI jobs failed. Exiting with error."
exit 1
fi
if [[ "$ALL_SUCCESS" == true ]]; then
echo "All required CircleCI jobs passed successfully!"
break
fi
echo "Waiting 20 seconds before checking again..."
echo "----------------------------------------"
sleep 20
done