Update to first user address block testing #60
Workflow file for this run
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: GitHub server installation | |
on: | |
push: | |
# Default opened, reopened, synchronize. "edited" is something else. | |
pull_request_target: | |
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 probably don't need this | |
# 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: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.x] | |
env: | |
NORMAL_USER_EMAIL: alkiln@example.com | |
NORMAL_USER_PASSWORD: User123^ | |
steps: | |
#### Developer note: You probably don't need this | |
# 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 `.` with the path to | |
#### the repo and branch. For example: | |
#### suffolkLITLab/ALKiln/action_for_github_server@v5 | |
uses: suffolkLITLab/ALKiln/action_for_github_server@v5 | |
with: | |
# CONFIG_CONTENTS: "${{ secrets.CONFIG_CONTENTS }}" | |
SHOW_DOCKER_OUTPUT: "${{ github.event.inputs.show_docker_output }}" | |
#### Developer note: Set this to True to show docker logs and | |
#### allow ALKiln to create the docker logs output artifact. | |
- 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: You probably don't need this | |
### Mia: may need this if tests log in | |
# - name: Run ALKiln - 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() }} | |
#### Developer note: you'll need to replace `.` with the path to | |
#### the repo and branch and leave off the trailing `/` | |
#### For example suffolkLITLab/ALKiln@v5 | |
uses: suffolkLITLab/ALKiln@v5 | |
with: | |
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: Useful for temporarily shortening ALKiln tests | |
#### to debug the docker install step | |
# ALKILN_TAG_EXPRESSION: "@1" | |