Skip to content

Commit

Permalink
test: improve E2E CI
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoaldamav committed Nov 2, 2023
1 parent 47d1de8 commit 43f9aef
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 13 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: E2E Tests

on:
pull_request:
branches:
- '**'
push:
branches:
- '**'

jobs:
get-team-members:
runs-on: ubuntu-latest
outputs:
team-members: ${{ steps.get-team-members.outputs.team-members }}
steps:
- name: Get team members from GitHub API
id: get-team-members
run: |
TEAM_MEMBERS=$(gh api /orgs/pnpm/teams/collaborators/members --paginate | jq -r '.[].login' | paste -sd, -)
echo "team-members=$TEAM_MEMBERS" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

check-author:
runs-on: ubuntu-latest
needs: get-team-members
outputs:
is-external: ${{ steps.check-author.outputs.is-external }}
steps:
- name: Check if PR is from a team member
id: check-author
run: |
TEAM_MEMBERS="${{ needs.get-team-members.outputs.team-members }}"
if [ "${{ github.event.pull_request }}" != "" ]; then
if echo "$TEAM_MEMBERS" | grep -q "${{ github.actor }}"; then
echo "PR is from a team member."
echo "is-external=false" >> $GITHUB_OUTPUT
else
echo "PR is from an external contributor."
echo "is-external=true" >> $GITHUB_OUTPUT
fi
else
echo "Not a PR, running the workflow."
echo "is-external=false" >> $GITHUB_OUTPUT
fi
require-approval:
runs-on: ubuntu-latest
needs: check-author
if: needs.check-author.outputs.is-external == 'true'
steps:
- name: Manual Approval
uses: actions/github-script@v6
with:
script: |
const prNumber = context.payload.pull_request.number;
const repo = context.repo;
github.rest.pulls.requestReviewers({
owner: repo.owner,
repo: repo.repo,
pull_number: prNumber,
reviewers: ['nachoaldamav']
});
github-token: ${{ secrets.GITHUB_TOKEN }}

windows-tests:
needs: [require-approval, get-team-members]
uses: ./.github/workflows/windows.yml@${{ github.ref_name }}

macos-tests:
needs: [require-approval, get-team-members]
uses: ./.github/workflows/macos.yml@${{ github.ref_name }}

linux-tests:
needs: [require-approval, get-team-members]
uses: ./.github/workflows/linux.yml@${{ github.ref_name }}
5 changes: 1 addition & 4 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
name: E2E Linux (Google Cloud)

on:
push:
branches:
- main
workflow_dispatch:
workflow_call:

jobs:
linux-e2e:
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
name: E2E MacOS (GitHub Actions)

on:
push:
branches:
- main
workflow_dispatch:

workflow_call:

jobs:
macos-e2e:
runs-on: macos-latest
Expand Down
5 changes: 1 addition & 4 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
name: E2E Windows (Google Cloud)

on:
push:
branches:
- main
workflow_dispatch:
workflow_call:

jobs:
windows-e2e:
Expand Down

0 comments on commit 43f9aef

Please sign in to comment.