forked from peter-evans/create-pull-request-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (141 loc) · 4.99 KB
/
pytest-command.yml
File metadata and controls
154 lines (141 loc) · 4.99 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: pytest-command
on:
repository_dispatch:
types: [pytest-command]
jobs:
clean:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Clean up pull requests and branches
- name: Close Pull Requests
uses: ./.github/close-pull-requests
- name: Close Pull Requests
uses: ./.github/close-pull-requests
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
repository: peter-evans/create-pull-request-tests-remote
- name: Close Pull Requests
uses: ./.github/close-pull-requests
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
repository: peter-evans/create-pull-request-tests-remote-private
# Delete the test branch created in the fork
- uses: actions/checkout@v2
with:
token: ${{ secrets.CPR_MACHINE_USER_TOKEN }}
repository: create-pull-request-machine-user/create-pull-request-tests
ref: master
path: create-pull-request-machine-user-fork
- name: Delete fork branches
working-directory: create-pull-request-machine-user-fork
run: |
git fetch
git push --force --delete origin refs/heads/tests/push-branch-to-fork || true
beforeTest:
needs: clean
runs-on: ubuntu-latest
steps:
# Get the target repository and branch
- name: Get the target repository and branch
id: vars
run: |
repository=${{ github.event.client_payload.slash_command.repository }}
if [[ -z "$repository" ]]; then repository="peter-evans/create-pull-request"; fi
echo ::set-output name=repository::$repository
branch=${{ github.event.client_payload.slash_command.branch }}
if [[ -z "$branch" ]]; then branch="master"; fi
echo ::set-output name=branch::$branch
build=${{ github.event.client_payload.slash_command.build }}
if [[ -z "$build" ]]; then build="false"; fi
echo ::set-output name=build::$build
# Checkout the branch to test
- uses: actions/checkout@v2
with:
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
repository: ${{ steps.vars.outputs.repository }}
ref: ${{ steps.vars.outputs.branch }}
# Build
- if: steps.vars.outputs.build == 'true'
uses: actions/setup-node@v1
with:
node-version: 12.x
- if: steps.vars.outputs.build == 'true'
uses: actions/setup-python@v2
with:
python-version: '3.x'
- if: steps.vars.outputs.build == 'true'
run: |
npm ci
npm run clean
npm run build
npm run format-check
npm run lint
npm run test
npm run package
rm -rf node_modules
# Create an artifact from the action
- uses: actions/upload-artifact@v1
with:
name: create-pull-request
path: .
createRunLink:
needs: beforeTest
runs-on: ubuntu-latest
steps:
- name: Create URL to the run output
id: vars
run: echo ::set-output name=run-url::https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID
- name: Update comment
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> [Command run output][1]
[1]: ${{ steps.vars.outputs.run-url }}
pytest:
needs: beforeTest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# Download the action artifact
- uses: actions/download-artifact@v1
with:
name: create-pull-request
path: create-pull-request-local
# Setup Python environment
- uses: actions/setup-python@v1
with:
python-version: '3.8.x'
# Install pytest
- name: Install pytest
run: |
pip install -U pytest
pytest --version
# Install requirements
- name: Install requirements
working-directory: create-pull-request-local/dist
run: pip install -r cpr/requirements.txt --no-index --find-links=vendor
# Execute pytest
- name: Execute pytest
env:
COUB_REPO_PATH: ${{ github.workspace }}
working-directory: create-pull-request-local
run: |
pytest ${{ github.event.client_payload.slash_command.unnamed_args }}
afterTest:
needs:
- createRunLink
- pytest
runs-on: ubuntu-latest
steps:
# Add reaction to the comment
- name: Add reaction
uses: peter-evans/create-or-update-comment@v1
with:
token: ${{ secrets.ACTIONS_BOT_TOKEN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
reaction-type: hooray