Skip to content

Add to CHANGELOG, correct/add diagrams. Mermaid needs "o" hack. #497

Add to CHANGELOG, correct/add diagrams. Mermaid needs "o" hack.

Add to CHANGELOG, correct/add diagrams. Mermaid needs "o" hack. #497

Workflow file for this run

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:
NORMAL_USER_EMAIL: alkiln@example.com
NORMAL_USER_PASSWORD: User123^
WRONG_EMAIL: wrong_email@example.com
WRONG_PASSWORD: wrong_password
INVALID_API_KEY: invalidAPIkey
EMPTY_STRING: ""
SECRET_VAR1: secret-var1-value
SECRET_VAR2: secret-var2-value
SECRET_FOR_MISSING_FIELD: secret for missing field
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: logs
#### 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_LOG_FILE: "${{ steps.alkiln.outputs.PATH_TO_REPORT_LOG_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"