diff --git a/.github/workflows/ci_test.yml b/.github/workflows/ci_test.yml new file mode 100644 index 0000000..87fed33 --- /dev/null +++ b/.github/workflows/ci_test.yml @@ -0,0 +1,76 @@ + +name: CsI only after 2 approvals + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review, review_requested] + pull_request_review: + types: [submitted] + +permissions: + contents: read + pull-requests: read + +jobs: + check-approvals: + runs-on: ubuntu-latest + outputs: + approved: ${{ steps.check.outputs.approved }} + count: ${{ steps.check.outputs.count }} + steps: + - name: Print event basics + run: | + echo "Event name : ${{ github.event_name }}" + echo "Event action : ${{ github.event.action }}" + echo "Review state : ${{ github.event.review.state || 'n/a' }}" + echo "PR number : ${{ github.event.pull_request.number }}" + + - name: Count unique latest approvals + id: check + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const owner = context.repo.owner; + const repo = context.repo.repo; + const prNumber = context.payload.pull_request.number; + + // Fetch all reviews for the PR + const { data: reviews } = await github.rest.pulls.listReviews({ + owner, repo, pull_number: prNumber, per_page: 100 + }); + + // Keep only the latest review per user + const latestByUser = new Map(); + for (const r of reviews) { + const key = r.user?.login; + const prev = latestByUser.get(key); + if (!prev || new Date(r.submitted_at) > new Date(prev.submitted_at)) { + latestByUser.set(key, r); + } + } + + // Count users whose latest state is APPROVED + const approvers = [...latestByUser.values()] + .filter(r => r.state === 'APPROVED') + .map(r => r.user.login); + + const count = approvers.length; + const threshold = 2; + + core.info(`Approvals (${count}): ${approvers.join(', ')}`); + core.setOutput('count', String(count)); + core.setOutput('approved', String(count >= threshold)); + + build: + needs: check-approvals + # Run only when the approval gate says "true" + if: needs.check-approvals.outputs.approved == 'true' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: | + echo "Approval count: ${{ needs.check-approvals.outputs.count }}" + echo "Running because at least 2 approvals are present." + # Place your real CI steps here (build/test/deploy etc.) + diff --git a/README.md b/README.md index 1fbcb04..8b2a232 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # h2xml - +#touch this +#this is attea ## Introduction H2XML (Header to XML) is a generic tool for generating XML files from annotated C header files with Grammar and syntax of the annotations are similar to