Merge pull request #22 from tspascoal/dependabot/npm_and_yarn/vercel/… #28
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: integration tests | |
on: | |
pull_request: | |
branches: 'master' | |
push: | |
branches: 'master' | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
env: | |
user: tspascoal | |
check-team: 'Team-1' | |
check-more-than-one-team: 'Team-No-Users, Team-1' | |
check-not-team: 'dummy2314332' | |
failed: "false" | |
organization: get-user-teams-membership-tests | |
steps: | |
- uses: actions/checkout@v3 | |
- name: build | |
run: | | |
npm install | |
npm run build | |
- name: Get Token | |
id: get_workflow_token | |
uses: peter-murray/workflow-application-token-action@v2 | |
with: | |
organization: ${{ env.organization }} | |
application_id: ${{ secrets.APPLICATION_ID }} | |
application_private_key: ${{ secrets.APPLICATION_PRIVATE_KEY }} | |
- name: Get Teams | |
uses: ./ | |
id: get-teams | |
with: | |
organization: ${{ env.organization }} | |
username: tspascoal | |
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }} | |
- name: validate teams | |
run: | | |
echo "found teams ${{ steps.get-teams.outputs.teams }}" | |
numberTeams=$(echo '${{ steps.get-teams.outputs.teams}}' | jq length) | |
if [ $numberTeams != 4 ]; then | |
echo "Expected 4 team membership for ${{ env.user }}" >> $GITHUB_SUMMARY | |
failed="true" | |
fi | |
if diff \ | |
< $(echo '["Team-1","Team-Secret","Parent","Child"]' | jq --sort-keys .) \ | |
< $(echo '${{ steps.get-teams.outputs.teams }}' | jq --sort-keys .) ; then | |
echo 'Teams mismatch ${{ steps.get-teams.outputs.teams }}' >> $GITHUB_SUMMARY | |
failed="true" | |
fi | |
echo "failed=$failed" >> $$GITHUB_ENV | |
- name: check if member of ${{ env.check-team }} | |
uses: ./ | |
id: check-teams-success | |
with: | |
organization: ${{ env.organization }} | |
username: tspascoal | |
team: ${{ env.check-team }} | |
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }} | |
- name: Not a team member? Fail | |
if: ${{ steps.check-teams-success.outputs.isTeamMember == 'false' }} | |
run: | | |
echo "failed=true" >> $$GITHUB_ENV | |
#################### Check if it belongs to at least one of two teams | |
- name: check if member of ${{ env.check-more-than-one-team }} | |
uses: ./ | |
id: check-more-than-one-team-success | |
with: | |
organization: ${{ env.organization }} | |
username: tspascoal | |
team: ${{ env.check-more-than-one-team }} | |
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }} | |
- name: Not a team member in at least one of the teams? Fail | |
if: ${{ steps.check-more-than-one-team-success.outputs.isTeamMember == 'false' }} | |
run: | | |
echo "Expected to belong to at least one team. Failing" | |
echo "failed=true" >> $$GITHUB_ENV | |
#################### | |
- name: check if member of ${{ env.check-not-team }} should not be | |
uses: ./ | |
id: check-not-team | |
with: | |
organization: ${{ env.organization }} | |
username: tspascoal | |
team: ${{ env.check-not-team }} | |
GITHUB_TOKEN: ${{ steps.get_workflow_token.outputs.token }} | |
- name: Dummy Team membership? Fail | |
if: ${{ steps.check-not-team.outputs.isTeamMember == 'true' }} | |
run: | | |
echo "failed=true" >> $$GITHUB_ENV | |
- name: Tests failed? | |
if: ${{ env.failed == 'true' }} | |
run: | |
exit 1 | |