-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre-commit
41 lines (35 loc) · 1.42 KB
/
pre-commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
set -e
# Nx provides built-in commands to run tasks for affected projects:
# - Run tests for affected projects:
# pnpm nx affected --target=test
# - Run linting for affected projects:
# pnpm nx affected --target=lint
#
# This script demonstrates how to manually calculate affected projects without relying on Nx, Bazel, or Make.
# Our rule-based approach standardizes the process, making it adaptable to diverse tech stacks and monorepo structures.
# docker run --rm -v ./:/app -w /app leblancmeneses/actions-affected:v3.0.4-60aac9c calculate --rules-file ./.github/affected.rules > affected.json
node dist/apps/affected/cli/main.cli.js calculate --rules-file ./.github/affected.rules > affected.json
if [[ ! -f affected.json ]]; then
echo "File does not exist: affected.json"
exit 1
fi
# Check properties
affected=$(jq '.changes.affected' affected.json)
pragma=$(jq '.changes.pragma' affected.json)
version_autopilot=$(jq '.changes.["version-autopilot"]' affected.json)
if [[ $affected == "true" ]]; then
npx nx run affected:lint
npx nx run affected:test
npx nx run affected:build:production --no-cache
fi
if [[ $pragma == "true" ]]; then
npx nx run pragma:lint
npx nx run pragma:test
npx nx run pragma:build:production --no-cache
fi
if [[ $version_autopilot == "true" ]]; then
npx nx run version-autopilot:lint
npx nx run version-autopilot:test
npx nx run version-autopilot:build:production --no-cache
fi
rm affected.json