-
Notifications
You must be signed in to change notification settings - Fork 24
113 lines (95 loc) · 3.56 KB
/
integration tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: integration tests
on:
pull_request:
branches: 'master'
push:
branches: 'master'
jobs:
test:
runs-on: ubuntu-latest
if: github.actor != 'dependabot[bot]'
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@v4
- name: build
run: |
npm install
npm run build
- name: Get Token
id: get_workflow_token
uses: peter-murray/workflow-application-token-action@v3
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