Skip to content

Commit

Permalink
Reference env vars with double brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
plocket committed Sep 10, 2024
1 parent 2e756db commit f318c2f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 51 deletions.
58 changes: 30 additions & 28 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ runs:
# Human-readable date/time: https://www.shell-tips.com/linux/how-to-format-date-and-time-in-linux-macos-and-bash/#how-to-format-a-date-in-bash
timestamp="$(date +'%Y-%m-%d at %Hh%Mm%Ss' -u)"
artifact_folder="alkiln-${timestamp}UTC"
echo "ARTIFACT_FOLDER=$artifact_folder" >> $GITHUB_ENV
debug_path="${artifact_folder}/debug_log.txt"
echo "DEBUG_PATH=$debug_path" >> $GITHUB_ENV
mkdir -p "$artifact_path"
echo "$log" >> "$debug_path"
# Action-specific vars
echo "ARTIFACT_FOLDER=$artifact_folder" >> $GITHUB_ENV
echo "DEBUG_PATH=$debug_path" >> $GITHUB_ENV
# Required for all tests
echo "REPO_URL=${{ github.server_url }}/${{ github.repository }}" >> $GITHUB_ENV
echo "BRANCH_PATH=$BRANCH_PATH" >> $GITHUB_ENV
# Workflow inputs
Expand All @@ -97,9 +99,9 @@ runs:
shell: bash
run: |
log="💡 ALK0024 INFO: Confirm environment variables"
echo -e "\n$log" >> "$DEBUG_PATH"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}"
vars_log="\nALKiln version is $ALKILN_VERSION\nRepo is $REPO_URL\nBranch ref is $BRANCH_PATH\nMAX_SECONDS_FOR_SETUP is $MAX_SECONDS_FOR_SETUP\nSERVER_RELOAD_TIMEOUT_SECONDS is $SERVER_RELOAD_TIMEOUT_SECONDS\n"
echo -e "$vars_log" >> "$DEBUG_PATH" && echo -e "$vars_log"
echo -e "$vars_log" >> "${{ env.DEBUG_PATH }}" && echo -e "$vars_log"
# Install
- name: "💡 ALK0025 INFO: Set up node"
Expand All @@ -110,7 +112,7 @@ runs:
shell: bash
run: |
log="💡 ALK0026 INFO: Install ALKiln directly from npm"
echo -e "\n$log" >> "$DEBUG_PATH"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}"
npm install -g "@suffolklitlab/alkiln@$ALKILN_VERSION"
# Install on playground
Expand All @@ -125,31 +127,31 @@ runs:
shell: bash
run: |
log="💡 ALK0027 INFO: Create a Project and install the package from GitHub"
echo -e "\n$log" >> "$DEBUG_PATH"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}"
pip install "docassemblecli==$DOCASSEMBLECLI_VERSION"
alkiln-setup --path="$ARTIFACT_FOLDER"
alkiln-setup --path="${{ env.ARTIFACT_FOLDER }}"
- name: "🤕 ALK0028 ERROR: Unable to create a Project"
if: ${{ inputs.INSTALL_METHOD == 'playground' && failure() }}
shell: bash
run: |
# "🤕 ALK0028 ERROR: Unable to create a Project"
long_log="\n\n―――\n🤕 ALK0028 ERROR: Unable to create a Project on your server's testing account or pull your package into it. Check the messages above this line.\n\n"
echo -e "$long_log" >> "$DEBUG_PATH" && echo -e "$long_log"
echo -e "$long_log" >> "${{ env.DEBUG_PATH }}" && echo -e "$long_log"
# Server installations - find folders and save session vars
- name: "💡 ALK0029 INFO: Install the GitHub package onto the server"
if: ${{ inputs.INSTALL_METHOD == 'server' }}
shell: bash
run: |
log="💡 ALK0029 INFO: Install the GitHub package onto the server"
echo -e "\n$log" >> "$DEBUG_PATH"
alkiln-server-install --path="$ARTIFACT_FOLDER"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}"
alkiln-server-install --path="${{ env.ARTIFACT_FOLDER }}"
- name: "🤕 ALK0030 ERROR: Unable to install the package"
if: ${{ inputs.INSTALL_METHOD == 'server' && failure() }}
shell: bash
run: |
log="\n\n―――\n🤕 ALK0030 ERROR: Unable to install the package on the temporary GitHub docassemble server. Check the steps above this line.\n\n"
echo -e "$log" >> "$DEBUG_PATH" && echo -e "$log"
echo -e "$log" >> "${{ env.DEBUG_PATH }}" && echo -e "$log"
# run tests
- name: "💡 ALK0031 INFO: Run tests"
Expand All @@ -159,17 +161,17 @@ runs:
shell: bash
run: |
log="💡 ALK0031 INFO: Run tests"
echo -e "\n$log" >> "$DEBUG_PATH"
alkiln-run "$ALKILN_TAG_EXPRESSION" --path="$ARTIFACT_FOLDER"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}"
alkiln-run "$ALKILN_TAG_EXPRESSION" --path="${{ env.ARTIFACT_FOLDER }}"
# on playground, delete project
- name: "💡 ALK0032 INFO: Delete the Project from the Playground"
if: ${{ always() && inputs.INSTALL_METHOD == 'playground' }}
shell: bash
run: |
log="💡 ALK0032 INFO: Delete the Project from the Playground"
echo -e "\n$log" >> "$DEBUG_PATH"
alkiln-takedown --path="$ARTIFACT_FOLDER"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}"
alkiln-takedown --path="${{ env.ARTIFACT_FOLDER }}"
# Upload artifacts that subscribers can download on the Actions summary page
- name: "💡 ALK0033 INFO: Upload artifacts folder"
Expand All @@ -192,16 +194,16 @@ runs:
shell: bash
run: |
log="💡 ALK0184 INFO: Prepare ALKiln output file paths"
echo -e "\n$log" >> "$DEBUG_PATH" && echo "$log"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}" && echo "$log"
FOLDER=$(ls -d */ | grep -E '^alkiln-*' || true)
log_folder="Test results artifacts folder is $FOLDER"
echo -e "\n$log_folder" >> "$DEBUG_PATH" && echo "$log_folder"
echo -e "\n$log_folder" >> "${{ env.DEBUG_PATH }}" && echo "$log_folder"
if [[ "$FOLDER" = "" ]]; then
log_missing="Artifacts folder is missing. The path is an empty string: '$FOLDER'"
echo -e "\n$log_missing" >> "$DEBUG_PATH" && echo "$log_missing"
echo -e "\n$log_missing" >> "${{ env.DEBUG_PATH }}" && echo "$log_missing"
else
REPORT_PATH="${FOLDER}report.txt"
Expand All @@ -210,30 +212,30 @@ runs:
DEBUG_LOG_PATH="${FOLDER}debug_log.txt"
if [ -f "$REPORT_PATH" ]; then
echo -e "\n$REPORT_PATH exists" >> "$DEBUG_PATH" && echo "$REPORT_PATH exists"
echo -e "\n$REPORT_PATH exists" >> "${{ env.DEBUG_PATH }}" && echo "$REPORT_PATH exists"
else
echo -e "\n$REPORT_PATH is missing" >> "$DEBUG_PATH" && echo "$REPORT_PATH is missing"
echo -e "\n$REPORT_PATH is missing" >> "${{ env.DEBUG_PATH }}" && echo "$REPORT_PATH is missing"
REPORT_PATH=""
fi
if [ -f "$REPORT_LOG_PATH" ]; then
echo -e "\n$REPORT_LOG_PATH exists" >> "$DEBUG_PATH" && echo "$REPORT_LOG_PATH exists"
echo -e "\n$REPORT_LOG_PATH exists" >> "${{ env.DEBUG_PATH }}" && echo "$REPORT_LOG_PATH exists"
else
echo -e "\n$REPORT_LOG_PATH is missing" >> "$DEBUG_PATH" && echo "$REPORT_LOG_PATH is missing"
echo -e "\n$REPORT_LOG_PATH is missing" >> "${{ env.DEBUG_PATH }}" && echo "$REPORT_LOG_PATH is missing"
REPORT_LOG_PATH=""
fi
if [ -f "$UNEXPECTED_RESULTS_PATH" ]; then
echo -e "\n$UNEXPECTED_RESULTS_PATH exists" >> "$DEBUG_PATH" && echo "$UNEXPECTED_RESULTS_PATH exists"
echo -e "\n$UNEXPECTED_RESULTS_PATH exists" >> "${{ env.DEBUG_PATH }}" && echo "$UNEXPECTED_RESULTS_PATH exists"
else
echo -e "\n$UNEXPECTED_RESULTS_PATH is missing" >> "$DEBUG_PATH" && echo "$UNEXPECTED_RESULTS_PATH is missing"
echo -e "\n$UNEXPECTED_RESULTS_PATH is missing" >> "${{ env.DEBUG_PATH }}" && echo "$UNEXPECTED_RESULTS_PATH is missing"
UNEXPECTED_RESULTS_PATH=""
fi
if [ -f "$DEBUG_LOG_PATH" ]; then
echo -e "\n$DEBUG_LOG_PATH exists" >> "$DEBUG_PATH" && echo "$DEBUG_LOG_PATH exists"
echo -e "\n$DEBUG_LOG_PATH exists" >> "${{ env.DEBUG_PATH }}" && echo "$DEBUG_LOG_PATH exists"
else
echo -e "\n$DEBUG_LOG_PATH is missing" >> "$DEBUG_PATH" && echo "$DEBUG_LOG_PATH is missing"
echo -e "\n$DEBUG_LOG_PATH is missing" >> "${{ env.DEBUG_PATH }}" && echo "$DEBUG_LOG_PATH is missing"
DEBUG_LOG_PATH=""
fi
Expand All @@ -252,4 +254,4 @@ runs:
if: ${{ always() }}
run: |
log="💡 ALK0034 INFO: ALkiln finished running tests. See above for more details."
echo -e "\n$log" >> "$DEBUG_PATH" && echo "$log"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}" && echo "$log"
44 changes: 22 additions & 22 deletions action_for_github_server/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ runs:
DOCASSEMBLECLI_VERSION: ${{ inputs.DOCASSEMBLECLI_VERSION }}
run: |
log="💡ALK0001 INFO: Set environment variables"
echo -e "\n$log" >> "$DEBUG_PATH" && echo "$log"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}" && echo "$log"
echo "MAX_SECONDS_FOR_DOCKER=$MAX_SECONDS_FOR_DOCKER" >> $GITHUB_ENV
echo "DOCASSEMBLECLI_VERSION=$DOCASSEMBLECLI_VERSION" >> $GITHUB_ENV
Expand All @@ -83,7 +83,7 @@ runs:
shell: bash
run: |
log="💡 ALK0002 INFO: Create GitHub step output variables"
echo -e "\n$log" >> "$DEBUG_PATH"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}"
echo "DOCASSEMBLE_DEVELOPER_API_KEY=$DA_ADMIN_API_KEY" >> "$GITHUB_OUTPUT"
echo "DA_ADMIN_EMAIL=$DA_ADMIN_EMAIL" >> "$GITHUB_OUTPUT"
echo "DA_ADMIN_PASSWORD=$DA_ADMIN_PASSWORD" >> "$GITHUB_OUTPUT"
Expand All @@ -94,19 +94,19 @@ runs:
shell: bash
run: |
log="💡 ALK0003 INFO: Get config"
echo -e "\n$log" >> "$DEBUG_PATH"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}"
mkdir /tmp/config
# Worth making this silent by defining a variable with > /dev/null...?
if [ -n "$CONFIG" ]
then
log2="💡 ALK0004 INFO: The developer did provide a custom docassemble config file as an input into this action."
echo -e "\n$log2" >> "$DEBUG_PATH" echo "$log2"
echo -e "\n$log2" >> "${{ env.DEBUG_PATH }}" echo "$log2"
echo "$CONFIG" > /tmp/config/myconfig.yml
echo "CONFIG_ARGS=--env DA_CONFIG=/tmp/config/myconfig.yml --volume /tmp/config:/tmp/config " >> $GITHUB_ENV
else
log3="💡 ALK0005 INFO: The developer did NOT provide a custom docassemble config file as an input into this action. Docassemble will use its default config."
echo -e "\n$log3" >> "$DEBUG_PATH" echo "$log3"
echo -e "\n$log3" >> "${{ env.DEBUG_PATH }}" echo "$log3"
echo "CONFIG_ARGS=" >> $GITHUB_ENV
fi
Expand All @@ -122,13 +122,13 @@ runs:
shell: bash
run: |
log="💡 ALK0006 INFO: Determine docker logs visibility"
echo -e "\n$log" >> "$DEBUG_PATH"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}"
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "OUTPUT_DOCKER=$SHOW_DOCKER_OUTPUT" >> $GITHUB_ENV
echo -e "\n$SHOW_DOCKER_OUTPUT" >> "$DEBUG_PATH"
echo -e "\n$SHOW_DOCKER_OUTPUT" >> "${{ env.DEBUG_PATH }}"
else
echo "OUTPUT_DOCKER=false" >> $GITHUB_ENV
echo -e "\nfalse" >> "$DEBUG_PATH"
echo -e "\nfalse" >> "${{ env.DEBUG_PATH }}"
fi
# Messages about output
Expand All @@ -138,14 +138,14 @@ runs:
run: |
# 💡 ALK0007 INFO: ALKiln will now hide docker output
log="===\n💡 ALK0007 INFO: ALKiln will now hide docker output to avoid possibly showing details about your config. If you want to get output to see more of what is going on, use \"with:\" and set the input \"SHOW_DOCKER_OUTPUT\" to \"true\". This output will only be visible to those who can already see the action output, like people with admin or write permissions.\n==="
echo -e "\n$log" >> "$DEBUG_PATH" && echo -e "$log"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}" && echo -e "$log"
- name: "💡 ALK0008 INFO: ALKiln will show docker output"
if: ${{ env.OUTPUT_DOCKER == 'true' }}
shell: bash
run: |
# 💡 ALK0008 INFO: ALKiln will show docker output
log="===\n💡 ALK0008 INFO: ALKiln will show docker output. ALKiln cannot control this output. If you want to prevent output, use \"with:\" and set the input \"SHOW_DOCKER_OUTPUT\" to \"false\". This output will only be visible to those who can already see the action output, like people with admin or write permissions.\n==="
echo -e "\n$log" >> "$DEBUG_PATH" && echo -e "$log"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}" && echo -e "$log"
# TODO: Reduce these to 1 block by putting ` > /dev/null 2>&1` into an env var
# No docker output
Expand All @@ -156,7 +156,7 @@ runs:
shell: bash
run: |
log="💡 ALK0009 INFO: Download and start docker silently"
echo -e "\n$log" >> "$DEBUG_PATH"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}"
docker pull jhpyle/docassemble > /dev/null 2>&1
docker run --name docassemble_container \
--env DA_ADMIN_EMAIL="$DA_ADMIN_EMAIL" \
Expand All @@ -173,7 +173,7 @@ runs:
shell: bash
run: |
log="💡 ALK0010 INFO: Download and start docker"
echo -e "\n$log" >> "$DEBUG_PATH"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}"
docker pull jhpyle/docassemble
docker run --name docassemble_container \
--env DA_ADMIN_EMAIL="$DA_ADMIN_EMAIL" \
Expand All @@ -191,13 +191,13 @@ runs:
run: |
# 💡 ALK0011 INFO: The following messages are not docker output
log="💡 ALK0011 INFO: The following messages are NOT docker output, just ALKiln waiting for the server to start"
echo -e "\n$log" >> "$DEBUG_PATH" && echo -e "$log"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}" && echo -e "$log"
- name: "💡 ALK0012 INFO: Waiting for server to start"
shell: bash
run: |
log="💡 ALK0012 INFO: Waiting for server to start"
echo -e "\n$log" >> "$DEBUG_PATH"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}"
# Reset the SECONDS variable
SECONDS=0
Expand All @@ -207,27 +207,27 @@ runs:
response="start"
while [[ $response != *"200"* ]]; do
log2="💡 ALK0013 INFO: Time elapsed: $SECONDS seconds"
echo -e "\n$log2" >> "$DEBUG_PATH" && echo -e "$log2"
echo -e "\n$log2" >> "${{ env.DEBUG_PATH }}" && echo -e "$log2"
# Check if max seconds till loading has passed
if [[ $SECONDS -ge $MAX_SECONDS_FOR_DOCKER ]]; then
log3="🤕 ALK0014 ERROR: Timed out waiting for docker container to serve the site. If you want to give your docker container more timem to install, set the MAX_SECONDS_FOR_DOCKER input for this action."
echo -e "\n$log3" >> "$DEBUG_PATH" && echo -e "$log3"
echo -e "\n$log3" >> "${{ env.DEBUG_PATH }}" && echo -e "$log3"
exit 1
fi
# Set the variable to a new string value in each iteration
response=$(curl -o /dev/null -s -w "%{http_code}\n" http://localhost:80/health_check?ready=1)
log4="💡 ALK0015 INFO: Response is $response"
echo -e "\n$log4" >> "$DEBUG_PATH" && echo -e "$log4"
echo -e "\n$log4" >> "${{ env.DEBUG_PATH }}" && echo -e "$log4"
# Check if the string includes the desired text
if [[ $response == *"200"* ]]; then
log5="💡 ALK0016 SUCCESS: Success! The docker container is ready!"
echo -e "\n$log5" >> "$DEBUG_PATH" && echo -e "$log5"
echo -e "\n$log5" >> "${{ env.DEBUG_PATH }}" && echo -e "$log5"
else
log6="💡 ALK0017 INFO: The docker container is not ready yet. Will check again in 30 seconds."
echo -e "\n$log6" >> "$DEBUG_PATH" && echo -e "$log6"
echo -e "\n$log6" >> "${{ env.DEBUG_PATH }}" && echo -e "$log6"
sleep 30
fi
Expand Down Expand Up @@ -262,7 +262,7 @@ runs:
shell: bash
run: |
log="💡 ALK0019 INFO: Create docker artifact data"
echo -e "\n$log" >> "$DEBUG_PATH"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}"
echo "$(docker output docassemble_container)" >> "${{ env.DEBUG_PATH }}"
- name: "💡 ALK0020 INFO: Upload artifacts folder"
if: ${{ always() && env.OUTPUT_DOCKER == 'true' }}
Expand All @@ -275,10 +275,10 @@ runs:
if: ${{ success() }}
run: |
log="💡 ALK0021 SUCCESS: ALKiln created the docker container and started the server!"
echo -e "\n$log" >> "$DEBUG_PATH" && echo -e "$log"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}" && echo -e "$log"
- shell: bash
if: ${{ failure() }}
run: |
log="🤕 ALK0022 ERROR: Something went wrong. See above for more details."
echo -e "\n$log" >> "$DEBUG_PATH" && echo -e "$log"
echo -e "\n$log" >> "${{ env.DEBUG_PATH }}" && echo -e "$log"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@suffolklitlab/alkiln",
"version": "5.13.0-logs1",
"version": "5.13.0-logs2",
"description": "Integrated automated end-to-end testing with docassemble, puppeteer, and cucumber.",
"main": "lib/index.js",
"scripts": {
Expand Down

0 comments on commit f318c2f

Please sign in to comment.