Skip to content

Commit

Permalink
Test issue creation when non-tests fail
Browse files Browse the repository at this point in the history
  • Loading branch information
plocket committed May 30, 2024
1 parent 3f29d92 commit b9510b7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
36 changes: 32 additions & 4 deletions .github/workflows/github_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ jobs:
# relative paths to action files
- uses: actions/checkout@v4

- shell: bash
run: |
# Set initial status code
echo "AL_SERVER_STATUS=Good" >> $GITHUB_ENV
- 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`
Expand All @@ -70,6 +75,14 @@ jobs:
- run: echo "ALKiln finished starting the isolated GitHub docassemble server"
shell: bash

# Test failing to see what happens with issue creation
- run: exit 55
shell: bash

- shell: bash
if: ${{ failure() }}
run: echo "AL_SERVER_STATUS=Server setup failed" >> $GITHUB_ENV

# #### Developer note: You can probably leave this out
# # Optional debugging to explore things like docker issues
# - name: Docker debug tmate session
Expand Down Expand Up @@ -115,32 +128,47 @@ jobs:
ALKILN_TAG_EXPRESSION: "${{ env.ALKILN_TAG_EXPRESSION }}"
ALKILN_VERSION: output

- shell: bash
if: ${{ failure() && env.AL_SERVER_STATUS == 'Good' }} # only if not already failed
run: echo "AL_SERVER_STATUS=Tests failed" >> $GITHUB_ENV

#### Developer note: Example of making an issue when tests fail
# if: ${{ failure() && env.AL_SERVER_STATUS == 'Tests failed' }} # only for test failure
- shell: bash
if: ${{ failure() }}
id: files
env:
GH_TOKEN: ${{ github.token }}
run: |
# Make an issue with file contents or 'no file' message as part of the body
echo '1'
# ex: "alkiln-2024-05-23 at 10h35m08sUTC/"
FOLDER=$(ls -d */ | grep -E '^alkiln-*')
echo "$FOLDER"
# Tests that failed or had typos in the Step instructions
UNEXPECTED_RESULTS_PATH="${FOLDER}unexpected_results.txt"
# Other possibly useful files
# REPORT_PATH="${FOLDER}report.txt"
# DEBUG_LOG_PATH="${FOLDER}debug_log.txt"
echo "$UNEXPECTED_RESULTS_PATH"
if [ -f "$UNEXPECTED_RESULTS_PATH" ]; then
UNEXPECTED_RESULTS=$(cat "$UNEXPECTED_RESULTS_PATH")
else
UNEXPECTED_RESULTS="unexpected_results.txt does not exist. Something other than the tests may have failed."
if [ -f "$UNEXPECTED_RESULTS_PATH" ]; then \
UNEXPECTED_RESULTS=$(cat "$UNEXPECTED_RESULTS_PATH") \
else \
UNEXPECTED_RESULTS="unexpected_results.txt does not exist. Something other than the tests may have failed." \
fi
echo "$UNEXPECTED_RESULTS"
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_RESULTS" --repo "$GITHUB_REPOSITORY" --label "testing" --title "Parse file in outer workflow: Test if failed tests make issue"
echo "10"
- shell: bash
if: ${{ failure() && env.AL_SERVER_STATUS == 'Good' }} # only if not already failed
run: echo "AL_SERVER_STATUS=Issue creation failed" >> $GITHUB_ENV
10 changes: 5 additions & 5 deletions lib/utils/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const files = require(`./files` );
module.exports = reports = {};

reports.title = `Assembly Line Kiln Automated Testing Report - ${ (new Date()).toUTCString() }\n`;
reports.failures = [ `\n\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n🤕 Failed scenarios\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n` ];
reports.successes = [ `\n\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n🌈 Passed scenarios\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n` ];
// reports.warnings = [ `\n\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n🔎 Scenarios to check\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n` ];
// reports.undefineds = [ `\n\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n[langs icon] Scenarios with typos\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n` ];
reports.others = [ `\n\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n🔎 Other scenarios that did not pass\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n` ];
reports.failures = [ `\n\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n🤕 Failed scenarios\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n` ];
reports.successes = [ `\n\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n🌈 Passed scenarios\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n` ];
// reports.warnings = [ `\n\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n🔎 Scenarios to check\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n` ];
// reports.undefineds = [ `\n\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n[langs icon] Scenarios with typos\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n` ];
reports.others = [ `\n\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n🔎 Other scenarios that did not pass\n≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡≡\n` ];

reports.addReportHeading = function (scope, { scenario }) {
/** Return printable heading based on Scenario name and tags.
Expand Down

0 comments on commit b9510b7

Please sign in to comment.