|
| 1 | +name: Post-merge validation |
| 2 | +#todo: delete test-main |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main, test-main ] |
| 6 | + |
| 7 | +jobs: |
| 8 | + commit-format: |
| 9 | + name: Check commits are squashed and well formatted |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - name: Checkout code |
| 13 | + uses: actions/checkout@v4 |
| 14 | + with: |
| 15 | + fetch-depth: 0 |
| 16 | + - name: Check commits are squashed |
| 17 | + run: | |
| 18 | + # Check that only one commit was added to main |
| 19 | + PREVIOUS_COMMIT=$(git rev-parse HEAD~1) |
| 20 | + COMMITS_ADDED=$(git rev-list --count $PREVIOUS_COMMIT..HEAD) |
| 21 | +
|
| 22 | + echo "Previous commit: $(git rev-parse --short $PREVIOUS_COMMIT)" |
| 23 | + echo "Current commit: $(git rev-parse --short HEAD)" |
| 24 | + echo "Commits added: $COMMITS_ADDED" |
| 25 | +
|
| 26 | + if [ $COMMITS_ADDED -ne 1 ]; then |
| 27 | + echo "❌ Merge was not squashed! $COMMITS_ADDED commits were added to main" |
| 28 | + echo "Please use 'Squash and merge' when merging PRs" |
| 29 | + exit 1 |
| 30 | + fi |
| 31 | +
|
| 32 | + echo "✅ Merge was properly squashed (1 commit added)" |
| 33 | +
|
| 34 | + - name: Check commit format |
| 35 | + run: | |
| 36 | + # Validate the commit message format |
| 37 | + MESSAGE=$(git log --format=%s -n 1 HEAD) |
| 38 | + echo "Merged commit message: $MESSAGE" |
| 39 | +
|
| 40 | + SCHEMA_REGEX="^(🎨|⚡️|🔥|🐛|🚑️|✨|📝|🚀|💄|🎉|✅|🔒️|🔐|🔖|🚨|🚧|💚|⬇️|⬆️|📌|👷|📈|♻️|➕|➖|🔧|🔨|🌐|✏️|💩|⏪️|🔀|📦️|👽️|🚚|📄|💥|🍱|♿️|💡|🍻|💬|🗃️|🔊|🔇|👥|🚸|🏗️|📱|🤡|🥚|🙈|📸|⚗️|🔍️|🏷️|🌱|🚩|🥅|💫|🗑️|🛂|🩹|🧐|⚰️|🧪|👔|🩺|🧱|🧑💻|💸|🧵|🦺|✈️)\\([a-z0-9:-]+\\) [a-z].{1,50}" |
| 41 | +
|
| 42 | + if ! echo "$MESSAGE" | grep -qE "$SCHEMA_REGEX"; then |
| 43 | + echo "❌ Merged commit has invalid format: $MESSAGE" |
| 44 | + echo "Required format: <emoji>(<scope>) <subject>" |
| 45 | + exit 1 |
| 46 | + fi |
| 47 | +
|
| 48 | + echo "✅ Merged commit format is valid" |
| 49 | + lint-and-format: |
| 50 | + name: Lint and Format Check |
| 51 | + runs-on: ubuntu-latest |
| 52 | + steps: |
| 53 | + - uses: actions/checkout@v4 |
| 54 | + - name: Build dev image |
| 55 | + run: make build-dev |
| 56 | + - name: Run pre-commit hooks |
| 57 | + run: ./bin/git-pre-commit-hook |
| 58 | + build: |
| 59 | + name: Build All Services |
| 60 | + runs-on: ubuntu-latest |
| 61 | + steps: |
| 62 | + - uses: actions/checkout@v4 |
| 63 | + - name: Build all services |
| 64 | + run: make build |
0 commit comments