-
Notifications
You must be signed in to change notification settings - Fork 4
188 lines (167 loc) · 8.25 KB
/
github_server.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
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
name: GitHub server installation
on:
push:
pull_request:
workflow_dispatch:
inputs:
tags:
required: False
description: 'Optional. Use a "tag expression" specify which tagged tests to run (https://cucumber.io/docs/cucumber/api/#tag-expressions)'
show_docker_output:
required: false
default: false
type: boolean
description: 'Show the docker logs while building the GitHub server container. It will also save the docker log artifact. This might show sensitive config information.'
#### Developer note: You can probably leave this out
enable_tmate:
type: boolean
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
required: false
default: false
jobs:
github-server-tests:
#### Developer note: If you have both `push` and `pull_request` in the
#### `on` section (above), this avoids running double tests when someone
#### on the team makes a pull request
# 1: Trigger job on push or dispatch from this repository
# 2: Trigger job on pull request from a fork
if: (
github.event_name != 'pull_request'
&& ! github.event.pull_request.head.repo.fork
) || (
github.event_name == 'pull_request'
&& github.event.pull_request.head.repo.fork
)
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
#### Developer note: You can probably leave out these specific
#### environment variables. You may not even need the `env`
#### keyword or values at all. See
#### https://assemblyline.suffolklitlab.org/docs/alkiln/writing#env-vars
env:
SECRET_VAR1: secret-var1-value
SECRET_VAR2: secret-var2-value
SECRET_FOR_MISSING_FIELD: secret for missing field
INVALID_API_KEY: invalidAPIkey
EMPTY_STRING: ""
NORMAL_USER_EMAIL: alkiln@example.com
NORMAL_USER_PASSWORD: User123^
WRONG_EMAIL=wrong_email@example.com
WRONG_PASSWORD=wrong_password
steps:
# Place the root directory in this branch to access
# relative paths to action files
- uses: actions/checkout@v4
- name: "ALKiln - Start the isolated temporary docassemble server on GitHub"
id: github_server
#### Developer note: you'll need to replace `uses: ./action_for_github_server`
#### with the path to ALKiln’s repository name and branch name. For example,
#### for version 5, use the branch name `v5`:
#### `uses: suffolkLITLab/ALKiln/action_for_github_server@v5`
uses: ./action_for_github_server
with:
#### Developer note: Set this to "true" to show docker logs and
#### allow ALKiln to create the docker logs output artifact.
SHOW_DOCKER_OUTPUT: "${{ github.event.inputs.show_docker_output }}"
#### Developer note: You can probably leave this out
CONFIG_CONTENTS: "${{ secrets.CONFIG_CONTENTS }}"
- run: echo "ALKiln finished starting the isolated GitHub docassemble server"
shell: bash
#### Developer note: You can probably leave this out
- name: "Add a low-level user and their API key (in an env var)"
env:
SERVER_URL: "${{ steps.github_server.outputs.SERVER_URL }}"
KEY: ${{ steps.github_server.outputs.DOCASSEMBLE_DEVELOPER_API_KEY }}
run: |
# Create user and their API key
# Install json processor
sudo apt-get install jq
# https://docassemble.org/docs/api.html#user_new
user_data=$(curl -X POST \
${{ env.SERVER_URL }}/api/user/new \
-H 'Content-Type: application/json' \
-d '{
"key": "${{ env.KEY }}",
"username": "${{ env.NORMAL_USER_EMAIL }}",
"password": "${{ env.NORMAL_USER_PASSWORD }}"
}')
echo "User data:"
echo "$user_data"
user_id=$(echo "$user_data" | jq '.user_id' -r)
# https://docassemble.org/docs/api.html#api_user_user_id_api_post
new_key_with_quotes=$(curl -X POST \
${{ env.SERVER_URL }}/api/user/"$user_id"/api \
-H 'Content-Type: application/json' \
-d '{
"key": "${{ env.KEY }}",
"name": "alkiln_key",
"method": "none"
}')
echo "new key (watch out, this contains actual quotation marks): $new_key_with_quotes"
no_end_quote="${new_key_with_quotes%\"}"
unquoted="${no_end_quote#\"}"
echo "unquoted: $unquoted"
echo "NORMAL_USER_API_KEY=$unquoted" >> "$GITHUB_ENV"
#### Developer note: You can probably leave this out
## Optional debugging to explore things like docker issues
#- name: Docker debug tmate session
# #if: ${{ failure() && github.event.inputs.enable_tmate == 'true' }}
# uses: mxschmitt/action-tmate@v3
#### Developer note: You can probably leave this out
- name: "Create other env vars for our own tests from server output"
run: |
echo "USER1_EMAIL=${{ steps.github_server.outputs.DA_ADMIN_EMAIL }}" >> $GITHUB_ENV
echo "USER1_PASSWORD=${{ steps.github_server.outputs.DA_ADMIN_PASSWORD }}" >> $GITHUB_ENV
#### Developer note:
#### Example of working with the docker container after it's been
#### started. For example, you can make more users with different
#### permissions and passwords
#- name: Work with docker
# run: |
# container_name=$(docker ps --format '{{.Names}}' | head -n 1)
# echo "container_name is $container_name"
- name: "Run ALKiln tests"
if: ${{ success() }}
id: alkiln
#### Developer note: you'll need to replace `uses: ./`
#### with the path to ALKiln’s repository name and branch name. For example,
#### for version 5, use the branch name `v5`: `uses: suffolkLITLab/ALKiln@v5`
uses: ./
#### Developer note: You can probably leave out this `env` section
env:
# Internal: docassemble changes sometimes break @a11y tests. That is
# a da problem, not ours. We will trigger these tests manually when we
# want to check up on this.
ALKILN_TAG_EXPRESSION: "${{ (github.event.inputs.tags && format('{0}', github.event.inputs.tags)) || '(not @error) and (not @temp_error)' }}"
with:
#### Developer note: Required inputs. See
#### https://assemblyline.suffolklitlab.org/docs/alkiln/writing/#sandbox-inputs
SERVER_URL: "${{ steps.github_server.outputs.SERVER_URL }}"
DOCASSEMBLE_DEVELOPER_API_KEY: "${{ steps.github_server.outputs.DOCASSEMBLE_DEVELOPER_API_KEY }}"
INSTALL_METHOD: "server"
#### Developer note: You can probably leave the rest out
#### To learn more, see https://assemblyline.suffolklitlab.org/docs/alkiln/writing/#optional-inputs
ALKILN_TAG_EXPRESSION: "${{ env.ALKILN_TAG_EXPRESSION }}"
ALKILN_VERSION: delete
#### Developer note: Example of making an issue when tests fail
#### that includes the text of the failure output file
#### See https://cli.github.com/manual/gh_issue_create for more details
- shell: bash
if: ${{ failure() }}
env:
GH_TOKEN: ${{ github.token }}
PATH_TO_REPORT_FILE: "${{ steps.alkiln.outputs.PATH_TO_REPORT_FILE }}"
PATH_TO_UNEXPECTED_RESULTS_FILE: "${{ steps.alkiln.outputs.PATH_TO_UNEXPECTED_RESULTS_FILE }}"
PATH_TO_DEBUG_LOG_FILE: "${{ steps.alkiln.outputs.PATH_TO_DEBUG_LOG_FILE }}"
run: |
# Make an issue with file contents or 'no file' message as part of the body
if [ -f "${{ env.PATH_TO_UNEXPECTED_RESULTS_FILE }}" ]; then
UNEXPECTED_2=$(cat "${{ env.PATH_TO_UNEXPECTED_RESULTS_FILE }}")
else
UNEXPECTED_2="unexpected_results.txt does not exist. Something other than the interview tests may have failed."
fi
gh issue create --body "An ALKiln test run failed. See the action at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}.
### Results:
$UNEXPECTED_2" --repo "$GITHUB_REPOSITORY" --label "testing" --title "ALKiln tests failed"