@suffolklitlab/alkiln 5.0.2-feat-github-server-10 → 5.0.2-feat-github-server-11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -28,8 +28,9 @@ jobs:
|
|
|
28
28
|
node-version: [18.x]
|
|
29
29
|
|
|
30
30
|
env:
|
|
31
|
-
USER1_EMAIL: admin@example.com
|
|
32
|
-
USER1_PASSWORD:
|
|
31
|
+
# USER1_EMAIL: admin@example.com
|
|
32
|
+
# USER1_PASSWORD: "@12lsdnejewng"
|
|
33
|
+
# How would a dev make another user/password if they wanted to?
|
|
33
34
|
SECRET_VAR1: secret-var1-value
|
|
34
35
|
SECRET_VAR2: secret-var2-value
|
|
35
36
|
SECRET_FOR_MISSING_FIELD: secret for missing field
|
|
@@ -50,6 +51,16 @@ jobs:
|
|
|
50
51
|
CONFIG_CONTENTS: "${{ secrets.CONFIG_CONTENTS }}"
|
|
51
52
|
- run: echo "Finished starting the GitHub server"
|
|
52
53
|
|
|
54
|
+
- name: Set more env vars
|
|
55
|
+
run: |
|
|
56
|
+
echo "USER1_EMAIL=${{ steps.github_server.outputs.DA_ADMIN_EMAIL }}" >> $GITHUB_ENV
|
|
57
|
+
echo "USER1_PASSWORD=${{ steps.github_server.outputs.DA_ADMIN_PASSWORD }}" >> $GITHUB_ENV
|
|
58
|
+
- name: Work with docker
|
|
59
|
+
run: |
|
|
60
|
+
# Authors can use this to do more with the docker container
|
|
61
|
+
container_name=$(docker ps --format '{{.Names}}' | head -n 1)
|
|
62
|
+
echo "container_name is $container_name"
|
|
63
|
+
|
|
53
64
|
- name: "Run ALKiln tests"
|
|
54
65
|
if: ${{ success() }}
|
|
55
66
|
uses: ./
|
|
@@ -58,6 +69,6 @@ jobs:
|
|
|
58
69
|
DOCASSEMBLE_DEVELOPER_API_KEY: "${{ steps.github_server.outputs.DOCASSEMBLE_DEVELOPER_API_KEY }}"
|
|
59
70
|
INSTALL_METHOD: "server"
|
|
60
71
|
# TODO: See what happens if this is an empty string
|
|
61
|
-
ALKILN_VERSION: "5.0.2-feat-github-server-
|
|
72
|
+
ALKILN_VERSION: "5.0.2-feat-github-server-11"
|
|
62
73
|
- run: echo "Finished running ALKiln tests"
|
|
63
74
|
|
package/action.yml
CHANGED
|
@@ -75,7 +75,7 @@ runs:
|
|
|
75
75
|
# Install on server
|
|
76
76
|
- name: "ALKiln: Install the GitHub package onto the server"
|
|
77
77
|
if: ${{ inputs.INSTALL_METHOD == 'server' }}
|
|
78
|
-
run: alkiln-
|
|
78
|
+
run: alkiln-server-install
|
|
79
79
|
shell: bash
|
|
80
80
|
- run: echo -e "\n\n====\nALKiln could not install the package on the temporary GitHub docassemble server. Check the steps above this line.\n\n"
|
|
81
81
|
if: ${{ inputs.INSTALL_METHOD == 'server' && failure() }}
|
package/github_server/action.yml
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
name: "ALKiln/github_server: Isolated docassemble tests"
|
|
2
2
|
description: "Download and start up a temporary docassemble server on GitHub's servers, in an isolated environment. Avoids docassemble reload errors and other external factors."
|
|
3
3
|
|
|
4
|
-
# Wat? Exit with 52
|
|
4
|
+
# Wat? Exit with 52
|
|
5
5
|
# https://github.com/SuffolkLITLab/ALKiln/actions/runs/5912900256/job/16036751264#step:4:188
|
|
6
6
|
# Had no completion messages, but it exited with an error anyway
|
|
7
7
|
# Took 121 seconds
|
|
8
8
|
# The rerun of the test completed that step just fine, though it took less time
|
|
9
9
|
# Took 120 and was fine: https://github.com/SuffolkLITLab/ALKiln/actions/runs/5913167036/job/16037288791
|
|
10
|
-
# 150:
|
|
11
|
-
# https://github.com/SuffolkLITLab/ALKiln/actions/runs/5914677262/job/16040233419
|
|
10
|
+
# 150 secs with exit code 56:
|
|
11
|
+
# https://github.com/SuffolkLITLab/ALKiln/actions/runs/5914677262/job/16040233419#step:4:196
|
|
12
|
+
# 120 sec with exit code 56:
|
|
13
|
+
# https://github.com/SuffolkLITLab/ALKiln/actions/runs/5914963614/job/16040773624#step:4:206
|
|
12
14
|
|
|
13
15
|
inputs:
|
|
14
16
|
CONFIG_CONTENTS:
|
|
@@ -27,17 +29,15 @@ outputs:
|
|
|
27
29
|
description: "Use this inside `with:` for the ALKiln step. URL of the temporary docassemble server."
|
|
28
30
|
value: "http://localhost"
|
|
29
31
|
DA_ADMIN_EMAIL:
|
|
30
|
-
|
|
31
|
-
value: "admin@example.com"
|
|
32
|
+
value: ${{ steps.api_key_output_step.outputs.DA_ADMIN_EMAIL }}
|
|
32
33
|
DA_ADMIN_PASSWORD:
|
|
33
|
-
|
|
34
|
-
value: "password"
|
|
34
|
+
value: ${{ steps.api_key_output_step.outputs.DA_ADMIN_PASSWORD }}
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
runs:
|
|
38
38
|
using: "composite"
|
|
39
39
|
steps:
|
|
40
|
-
- name: "github_server: Set environment variables"
|
|
40
|
+
- name: "ALKiln github_server: Set environment variables"
|
|
41
41
|
run: |
|
|
42
42
|
echo "DA_ADMIN_API_KEY=abcd1234abcd1234abcd5678abdc5678" >> $GITHUB_ENV
|
|
43
43
|
echo "MAX_SECONDS_FOR_DOCKER=${{ inputs.MAX_SECONDS_FOR_DOCKER }}" >> $GITHUB_ENV
|
|
@@ -45,7 +45,8 @@ runs:
|
|
|
45
45
|
echo "OWNER_AND_REPO_NAME=${{ github.repository }}" >> $GITHUB_ENV
|
|
46
46
|
echo "BRANCH_REF=${{ github.ref }}" >> $GITHUB_ENV
|
|
47
47
|
echo "DA_ADMIN_EMAIL=admin@example.com" >> $GITHUB_ENV
|
|
48
|
-
|
|
48
|
+
# Login will fail if this is "password"
|
|
49
|
+
echo "DA_ADMIN_PASSWORD=@123abcdefg" >> $GITHUB_ENV
|
|
49
50
|
shell: bash
|
|
50
51
|
- id: api_key_output_step
|
|
51
52
|
run: |
|
|
@@ -53,14 +54,14 @@ runs:
|
|
|
53
54
|
echo "::set-output name=DA_ADMIN_EMAIL::$DA_ADMIN_EMAIL"
|
|
54
55
|
echo "::set-output name=DA_ADMIN_PASSWORD::$DA_ADMIN_PASSWORD"
|
|
55
56
|
shell: bash
|
|
56
|
-
- name: "github_server: Download and start docker"
|
|
57
|
+
- name: "ALKiln github_server: Download and start docker"
|
|
57
58
|
run: |
|
|
58
59
|
mkdir /tmp/config
|
|
59
|
-
echo "${{ inputs.CONFIG_CONTENTS }}" > /tmp/config/myconfig.yml
|
|
60
|
+
echo "${{ inputs.CONFIG_CONTENTS }}" > /tmp/config/myconfig.yml
|
|
60
61
|
docker pull jhpyle/docassemble
|
|
61
|
-
docker run --env DA_ADMIN_EMAIL="
|
|
62
|
+
docker run --env DA_ADMIN_EMAIL="${{ env.DA_ADMIN_EMAIL }}" --env DA_ADMIN_PASSWORD="${{ env.DA_ADMIN_PASSWORD }}" --env DA_ADMIN_API_KEY="${{ env.DA_ADMIN_API_KEY }}" --env DA_CONFIG=/tmp/config/myconfig.yml --volume /tmp/config:/tmp/config --cap-add SYS_PTRACE --memory="4gb" -d -p 80:80 jhpyle/docassemble
|
|
62
63
|
shell: bash
|
|
63
|
-
- name: "github_server: Wait for server to start"
|
|
64
|
+
- name: "ALKiln github_server: Wait for server to start"
|
|
64
65
|
run: |
|
|
65
66
|
# github_server: Wait for server to start
|
|
66
67
|
|
|
@@ -99,7 +100,8 @@ runs:
|
|
|
99
100
|
done
|
|
100
101
|
shell: bash
|
|
101
102
|
|
|
102
|
-
- name: Install the package
|
|
103
|
+
- name: "ALKiln github_server: Install the package"
|
|
104
|
+
id: container_output_step
|
|
103
105
|
run: |
|
|
104
106
|
echo "CLONE_URL is $CLONE_URL"
|
|
105
107
|
git clone $CLONE_URL
|
|
@@ -121,17 +123,25 @@ runs:
|
|
|
121
123
|
cd ..
|
|
122
124
|
pip install docassemblecli
|
|
123
125
|
dainstall $repo_name --apiurl http://localhost --apikey $DA_ADMIN_API_KEY
|
|
124
|
-
|
|
125
|
-
## Below here is just for development
|
|
126
|
-
#container_name=$(docker ps --format '{{.Names}}' | head -n 1)
|
|
127
|
-
#echo $container_name
|
|
128
|
-
#docker exec -it "$container_name /bin/bash"
|
|
129
|
-
#echo "ls /usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble"
|
|
130
126
|
shell: bash
|
|
131
127
|
|
|
132
|
-
|
|
128
|
+
# Upload artifacts that subscribers can download on the Actions summary page
|
|
129
|
+
- name: "ALKiln github_server: Docker logs"
|
|
133
130
|
if: ${{ always() }}
|
|
134
|
-
# TODO: create an arifact for this instead
|
|
135
131
|
run: |
|
|
136
|
-
docker logs $(docker ps --filter "ancestor=jhpyle/docassemble" --format {{.ID}})
|
|
132
|
+
docker_logs=$(docker logs $(docker ps --filter "ancestor=jhpyle/docassemble" --format {{.ID}}))
|
|
133
|
+
# Should this name have a date/time attached? The logs themselves have timestamps
|
|
134
|
+
echo "$docker_logs" > /tmp/alkiln_docker_logs.txt
|
|
135
|
+
shell: bash
|
|
136
|
+
|
|
137
|
+
# Should this date/time be created at the start of this action?
|
|
138
|
+
- name: "ALKiln github_server: Get folder name with date and time"
|
|
139
|
+
run: |
|
|
140
|
+
echo "GITHUB_SERVER_ARTIFACT_NAME=alkiln-github-server-$(date +'%Y-%m-%d at %Hh%Mm%Ss' -u)UTC" >> $GITHUB_ENV
|
|
137
141
|
shell: bash
|
|
142
|
+
- name: "ALKiln github_server: Upload artifacts folder"
|
|
143
|
+
if: ${{ always() }}
|
|
144
|
+
uses: actions/upload-artifact@v3
|
|
145
|
+
with:
|
|
146
|
+
name: ${{ env.GITHUB_SERVER_ARTIFACT_NAME }}
|
|
147
|
+
path: /tmp/alkiln_docker_logs.txt
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
//const da_i = require('./docassemble_api_interface');
|
|
4
|
+
const session_vars = require('../utils/session_vars');
|
|
5
|
+
|
|
6
|
+
const server_install = async () => {
|
|
7
|
+
// let task_id = await da_i.install_on_server();
|
|
8
|
+
// if (task_id) {
|
|
9
|
+
// console.log("Waiting...")
|
|
10
|
+
// await da_i.wait_for_package_to_restart(task_id);
|
|
11
|
+
// }
|
|
12
|
+
// console.log("Done!")
|
|
13
|
+
|
|
14
|
+
session_vars.save_install_type("server");
|
|
15
|
+
|
|
16
|
+
}; // Ends server_install();
|
|
17
|
+
|
|
18
|
+
server_install();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suffolklitlab/alkiln",
|
|
3
|
-
"version": "5.0.2-feat-github-server-
|
|
3
|
+
"version": "5.0.2-feat-github-server-11",
|
|
4
4
|
"description": "Integrated automated end-to-end testing with docassemble, puppeteer, and cucumber.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"local": "npm run setup && npm run cucumber; npm run takedown",
|
|
10
10
|
"setup": "./lib/docassemble/setup.js",
|
|
11
11
|
"takedown": "./lib/docassemble/takedown.js",
|
|
12
|
-
"
|
|
12
|
+
"server_install": "./lib/docassemble/server_install.js",
|
|
13
13
|
"unit": "mocha tests/unit_tests/*.test.*"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"uuid": "8.3.2"
|
|
49
49
|
},
|
|
50
50
|
"bin": {
|
|
51
|
-
"alkiln-
|
|
51
|
+
"alkiln-server-install": "./lib/docassemble/server_install.js",
|
|
52
52
|
"alkiln-setup": "./lib/docassemble/setup.js",
|
|
53
53
|
"alkiln-takedown": "./lib/docassemble/takedown.js",
|
|
54
54
|
"alkiln-run": "./lib/run_cucumber.js"
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const puppeteer = require('puppeteer');
|
|
3
|
-
const da_i = require('./docassemble_api_interface');
|
|
4
|
-
const session_vars = require('../utils/session_vars');
|
|
5
|
-
|
|
6
|
-
const fs = require('fs')
|
|
7
|
-
|
|
8
|
-
const startserver = async () => {
|
|
9
|
-
// Open the browser, login with env var creds
|
|
10
|
-
/*
|
|
11
|
-
let browser = await puppeteer.launch({headless: !session_vars.get_debug()})
|
|
12
|
-
let page = await browser.newPage();
|
|
13
|
-
// Go to the sign in page
|
|
14
|
-
let login_url = `${ session_vars.get_da_server_url() }/user/sign-in`;
|
|
15
|
-
try {
|
|
16
|
-
// puppeteer will ensure proper timeout.
|
|
17
|
-
await page.goto( login_url, { waitUntil: `domcontentloaded`, timeout: 3000 });
|
|
18
|
-
await page.waitForSelector( `.dabody` );
|
|
19
|
-
} catch ( error ) {
|
|
20
|
-
let err_msg = `Error occurred when ALKiln tried to go to "${ login_url }: ${ error }".`
|
|
21
|
-
console.log(err_msg);
|
|
22
|
-
throw error;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
let email = process.env[ "DA_ADMIN_API_KEY" ];
|
|
26
|
-
let password = process.env[ "USER_PASSWORD" ];
|
|
27
|
-
|
|
28
|
-
// Try to log in
|
|
29
|
-
await page.type( `#email`, email );
|
|
30
|
-
await page.type( `#password`, password );
|
|
31
|
-
let elem = await page.$( `button[name="submit"]` );
|
|
32
|
-
await elem.click();
|
|
33
|
-
await page.waitForNavigation({waitUntil: 'domcontentloaded'});
|
|
34
|
-
|
|
35
|
-
// Wait to see the success message.
|
|
36
|
-
// This is a bit of an assumption and needs success and failure testing
|
|
37
|
-
// TODO: use a Promise.race to fail faster.
|
|
38
|
-
await page.waitForSelector( `.datopcenter .alert-success` );
|
|
39
|
-
// make an API key
|
|
40
|
-
|
|
41
|
-
// TODO(brycew): with or without the API key?
|
|
42
|
-
// Install the package in order to also install all of its dependencies
|
|
43
|
-
let api_key_url = `${ session_vars.get_da_server_url() }/manage_api?action=new`;
|
|
44
|
-
await page.goto( api_key_url, { waitUntil: `domcontentloaded`, timeout: 3000 });
|
|
45
|
-
await page.type( `#name`, "ALKiln tmp key");
|
|
46
|
-
await page.select( `#method`, "none");
|
|
47
|
-
let winner = await Promise.all([page.click(`#submit`), page.waitForNavigation({waitUntil: 'domcontentloaded'})]);
|
|
48
|
-
console.log(`submitted`);
|
|
49
|
-
const api_text = await page.$eval('body p code', elem => elem.innerText);
|
|
50
|
-
process.env.DOCASSEMBLE_DEVELOPER_API_KEY = api_text;
|
|
51
|
-
console.log(`api key: ${api_text}`);
|
|
52
|
-
let file = fs.writeFileSync( ".tmpenv", `export DOCASSEMBLE_DEVELOPER_API_KEY=${api_text}`);
|
|
53
|
-
|
|
54
|
-
await page.goto(`${ session_vars.get_da_server_url() }/user/sign-out`, {waitUntil: `domcontentloaded`});
|
|
55
|
-
console.log(`signed out`);
|
|
56
|
-
await browser.close();
|
|
57
|
-
*/
|
|
58
|
-
|
|
59
|
-
// let task_id = await da_i.install_on_server();
|
|
60
|
-
// if (task_id) {
|
|
61
|
-
// console.log("Waiting...")
|
|
62
|
-
// await da_i.wait_for_package_to_restart(task_id);
|
|
63
|
-
// }
|
|
64
|
-
// console.log("Done!")
|
|
65
|
-
session_vars.save_install_type("server");
|
|
66
|
-
|
|
67
|
-
}; // Ends startserver();
|
|
68
|
-
|
|
69
|
-
startserver();
|