-
Notifications
You must be signed in to change notification settings - Fork 28
173 lines (157 loc) · 6.08 KB
/
prtest.yaml
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
name: pr-test
on:
issue_comment:
types: [created]
jobs:
test-check:
runs-on: ubuntu-latest
steps:
- name: vet commenter
id: vet
if: github.event.comment.user.login != 'cellistigs'
run: exit 1
- name: acknowledge test request to commenter
id: check
uses: khan/pull-request-comment-trigger@master
with:
trigger: "#test:"
prefix_only: true
reaction: rocket
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: check outputs
run: echo ${{ steps.check.outputs.triggered }}
outputs:
triggered: ${{ steps.check.outputs.triggered }}
comment_body: ${{ github.event.comment.body }}
test:
runs-on: ubuntu-latest
needs: test-check
if: needs.test-check.outputs.triggered == 'true'
steps:
- name: get pull request ref
id: get_pull_request_ref
uses: octokit/[email protected]
with:
route: GET /repos/{owner}/{repo}/pulls/{issue_id}
owner: cunningham-lab
repo: neurocaas
repository: ${{ github.repository }}
issue_id: ${{ github.event.issue.number }}
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: create test
id: create_test
uses: octokit/[email protected]
with:
route: POST /repos/{owner}/{repo}/deployments
owner: cunningham-lab
repo: neurocaas
repository: ${{ github.repository }}
ref: ${{ fromJson(steps.get_pull_request_ref.outputs.data).head.ref }}
environment: dev
auto_merge: false
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: set test status to in progress
id: start_test
uses: octokit/[email protected]
with:
route: POST /repos/{owner}/{repo}/deployments/{deployment}/statuses
owner: cunningham-lab
repo: neurocaas
repository: ${{ github.repository }}
deployment: ${{ fromJson(steps.create_test.outputs.data).id }}
environment: dev
environment_url: https://example.com
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
state: in_progress
mediaType: '{"previews": ["flash", "ant-man"]}'
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: get stack name
uses: jungwinter/split@v1
id: split
with:
msg: "#test:test-tags-bucket" #${{ needs.test-check.outputs.comment_body }}
seperator: ':'
- name: Use the master repo to test.
uses: actions/checkout@v2
with:
persist-credentials: false
ref: ${{ fromJson(steps.get_pull_request_ref.outputs.data).base.sha }}
- name: setup python.
uses: actions/setup-python@v2
with:
python-version: 3.8
# Log in to docker hub.
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
# Configure AWS credentials.
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.DEPLOY_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEPLOY_AWS_SECRET_ACCESS_KEY }}
# aws-session-token: ${{ secrets.AWS_SESSION_TOKEN }} # if you have/need it
aws-region: us-east-1
- name: Install Repo.
run: |
cd $GITHUB_WORKSPACE
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
bash miniconda.sh -b -p $HOME/miniconda
source "$HOME/miniconda/etc/profile.d/conda.sh"
hash -r
conda config --set always_yes yes --set changeps1 no
conda update -q conda
conda config --append envs_dirs $HOME/miniconda/envs
conda create -n neurocaas
conda activate neurocaas
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install aws-sam-cli==0.53.0
pip install localstack==0.12.3
pip install ./
sudo apt-get install jq
- name: Test stack
run: |
cd ncap_iac/ncap_blueprints
source "$HOME/miniconda/etc/profile.d/conda.sh"
conda activate neurocaas
bash iac_utils/fulltest.sh ${{ steps.split.outputs._1 }}
- name: Set test status to success
id: successful_test
uses: octokit/[email protected]
with:
route: POST /repos/{owner}/{repo}/deployments/{deployment}/statuses
owner: cunningham-lab
repo: neurocaas
repository: ${{ github.repository }}
deployment: ${{ fromJson(steps.create_test.outputs.data).id }}
environment: dev
environment_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
mediaType: '{"previews": ["ant-man"]}'
state: success
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: set test status to failure
id: failed_test
uses: octokit/[email protected]
if: failure()
with:
route: POST /repos/{owner}/{repo}/deployments/{deployment}/statuses
owner: cunningham-lab
repo: neurocaas
repository: ${{ github.repository }}
deployment: ${{ fromJson(steps.create_test.outputs.data).id }}
environment: dev
environment_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
log_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
mediaType: '{"previews": ["ant-man"]}'
state: failure
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"