build-cloud-nx.yml•3.47 kB
name: CI
on:
pull_request:
permissions:
actions: read
contents: read
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
jobs:
main:
runs-on: ubuntu-latest
if: github.repository == 'activepieces/activepieces'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: 20
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- run: bun install
- run: npx nx reset
- uses: nrwl/nx-set-shas@v4
- name: List all nx targets
run: npx nx show projects --all
- name: Get changed files
id: changed-files
run: echo "files=$(git diff --name-only HEAD origin/main | tr '\n' ' ')" >> $GITHUB_OUTPUT
- name: Check if framework or common pieces are changed
id: check-framework-common
run: |
CHANGED_FILES="${{ steps.changed-files.outputs.files }}"
if echo "$CHANGED_FILES" | grep -q "community/framework\|community/common"; then
echo "framework_or_common_changed=true" >> $GITHUB_OUTPUT
else
echo "framework_or_common_changed=false" >> $GITHUB_OUTPUT
fi
- name: Extract pieces projects from changed files
id: extract-pieces
run: |
PIECES=$(echo "${{ steps.changed-files.outputs.files }}" | grep -o "packages/pieces/[^/]*/[^/]*/" | awk -F'/' '{print "pieces-" $4}' | sort -u | tr '\n' ',' | sed 's/,$//')
echo "pieces_projects=$PIECES" >> $GITHUB_OUTPUT
- name: Lint affected projects excluding pieces
run: npx nx affected --target=lint --exclude="pieces-*"
- name: Lint changed pieces projects
if: steps.extract-pieces.outputs.pieces_projects != '' && steps.check-framework-common.outputs.framework_or_common_changed == 'false'
run: npx nx run-many --target=lint --projects="${{ steps.extract-pieces.outputs.pieces_projects }}"
- name: Lint all pieces projects
if: steps.check-framework-common.outputs.framework_or_common_changed == 'true'
run: npx nx run-many --target=lint --projects="pieces-*"
- name: Build affected projects excluding pieces
run: npx nx affected --target=build -c production --exclude="pieces-*"
- name: Build changed pieces projects
if: steps.extract-pieces.outputs.pieces_projects != '' && steps.check-framework-common.outputs.framework_or_common_changed == 'false'
run: npx nx run-many --target=build -c production --projects="${{ steps.extract-pieces.outputs.pieces_projects }}"
- name: Build all pieces projects
if: steps.check-framework-common.outputs.framework_or_common_changed == 'true'
run: npx nx run-many --target=build -c production --projects="pieces-*"
- name: Run all tests in parallel
run: |
set -euo pipefail
pids=()
npx nx run-many --target=test --projects=engine,shared &
pids+=($!)
npx nx run server-api:test-ce &
pids+=($!)
npx nx run server-api:test-ee &
pids+=($!)
npx nx run server-api:test-cloud &
pids+=($!)
status=0
for pid in "${pids[@]}"; do
if ! wait "$pid"; then
status=1
fi
done
exit $status