diff --git a/.github/workflows/validate-commits.yml b/.github/workflows/check-commits.yml similarity index 94% rename from .github/workflows/validate-commits.yml rename to .github/workflows/check-commits.yml index bd054c8..fda61ae 100644 --- a/.github/workflows/validate-commits.yml +++ b/.github/workflows/check-commits.yml @@ -6,6 +6,7 @@ on: jobs: check-commits: + name: Validate Commit Messages runs-on: ubuntu-latest steps: diff --git a/.github/workflows/main-branch-pipeline.yml b/.github/workflows/main-branch-pipeline.yml new file mode 100644 index 0000000..ddca3d6 --- /dev/null +++ b/.github/workflows/main-branch-pipeline.yml @@ -0,0 +1,113 @@ +name: 🚀 Main Branch Pipeline + +on: + push: + branches: + - main + +jobs: + # Step 1: Validate merge source + validate-resource: + name: Validate merge source + runs-on: ubuntu-latest + outputs: + validated: ${{ steps.validate.outputs.result }} + steps: + - name: Check source branch + id: validate + run: | + if [ "${{ github.head_ref }}" != "develop" ]; then + echo "Error: Only develop branch can merge to main" + echo "result=failure" >> $GITHUB_OUTPUT + exit 1 + else + echo "Validation passed - source branch is develop" + echo "result=success" >> $GITHUB_OUTPUT + fi + + # Step 2: Validate commit messages + check-commits: + name: Validate Commit Messages + runs-on: ubuntu-latest + needs: validate-resource + if: needs.validate-resource.outputs.validated == 'success' + outputs: + commits-validated: ${{ steps.validate-commits.outputs.result }} + steps: + - name: ⬇️ Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: ⬢ Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: 📦 Install Commitlint + run: | + npm install --save-dev @commitlint/{config-conventional,cli} + + - name: 🔍 Validate commit messages (entire branch) + id: validate-commits + run: | + npx commitlint --from=$(git rev-list --max-parents=0 HEAD) --to=HEAD --verbose + echo "result=success" >> $GITHUB_OUTPUT + + # Step 3: Run Flutter tests + test: + name: Flutter Tests & Coverage + runs-on: ubuntu-latest + needs: check-commits + if: needs.check-commits.outputs.commits-validated == 'success' + outputs: + tests-passed: ${{ steps.run-tests.outputs.result }} + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Flutter + uses: subosito/flutter-action@v2 + with: + flutter-version: "3.29.3" + architecture: "x64" + + - name: Install dependencies + run: flutter pub get + + - name: Verify formatting + run: dart format --set-exit-if-changed . + + - name: Analyze project source + run: flutter analyze + + - name: Run tests with coverage + id: run-tests + run: | + flutter test --coverage + echo "result=success" >> $GITHUB_OUTPUT + + # Step 4: Release + release: + name: Release + runs-on: ubuntu-latest + needs: test + if: needs.test.outputs.tests-passed == 'success' + steps: + - name: ⬇️ Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: ⬢ Setup Node + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: 📦 Install dependencies + run: npm ci + + - name: 🚀 Run semantic-release + env: + GH_TOKEN: ${{ secrets.GH_TOKEN }} + run: npx semantic-release diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9c904f8..b7367d6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,10 +3,11 @@ name: 🚀 Release on: push: branches: - - main # The branch you want to release from + - develop # Moved to develop branch for testing releases jobs: release: + name: Release runs-on: ubuntu-latest steps: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1fd7a83..2f99b06 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,12 +2,15 @@ name: Flutter Tests & Coverage on: push: - branches: [main, develop] + branches: + - develop pull_request: - branches: [main, develop] + branches: + - develop jobs: test: + name: Flutter Tests & Coverage runs-on: ubuntu-latest steps: diff --git a/.github/workflows/validate-resource.yml b/.github/workflows/validate-resource.yml index 21ab3ed..43c1f1c 100644 --- a/.github/workflows/validate-resource.yml +++ b/.github/workflows/validate-resource.yml @@ -1,15 +1,24 @@ name: Validate merge source on: - pull_request: - branches: [main] + push: + branches: + - main jobs: - validate: + validate-resource: + name: Validate merge source runs-on: ubuntu-latest + outputs: + validated: ${{ steps.validate.outputs.result }} steps: - name: Check source branch + id: validate run: | if [ "${{ github.head_ref }}" != "develop" ]; then echo "Error: Only develop branch can merge to main" + echo "result=failure" >> $GITHUB_OUTPUT exit 1 + else + echo "Validation passed - source branch is develop" + echo "result=success" >> $GITHUB_OUTPUT fi