-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor action.yml to set working directory before script execution (#…
…11) * Refactor action.yml to set working directory before script execution * Remove unnecessary directory changes in action.yml and copy script to workspace * Remove caching of npm dependencies and update installation command in action.yml * try to use dist * Meh * move http-server into action * add required shell keywords * cp: '/home/runner/work/webapp-console-log-action/webapp-console-log-action/.//dist' and './dist' are the same file * run common JS on the fly * remove path * try to execute capture script directly without transforming to CJS * remove unnecessary packages * create index html file on the fly * debug file outputs * use weird suggestion from Github Copilot to access the file * get the artifact inside the action * remove debug steps * Revert "remove debug steps" This reverts commit 29d8e53. * add debug steps back * set working directory * set working directory * list directories * change directories while running * debug cd * cd has actually no effect!! * syntax * syntax * store action path * use stored path * remove debug * add port and tests * checkout * read port from env not from input * pass the fails if the fail fails successfully 😅 * fi * continue-on-error * check step instead of job * it's outcome not status * update README.md
- Loading branch information
Showing
13 changed files
with
522 additions
and
338 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: "Negative Test - all defaults" | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
- closed | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
jobs: | ||
fail: | ||
runs-on: ubuntu-latest | ||
name: Should fail - has warnings and errors, uses all defaults | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Create fake App with console outputs | ||
run: | | ||
touch index.html | ||
cat > index.html << EOF | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>New Page</title> | ||
</head> | ||
<body> | ||
<h1>Hello, World!</h1> | ||
<script> | ||
console.debug('This is a debug message and likely hidden in the fail workflow'); | ||
console.info('This is an info in the fail workflow'); | ||
console.log('This is a log in the fail workflow'); | ||
console.log('This is another log in the fail workflow'); | ||
console.warn('This is a warning in the fail workflow'); | ||
console.error('This is an error in the fail workflow'); | ||
</script> | ||
</body> | ||
</html> | ||
|
||
EOF | ||
|
||
- name: Upload index.html | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: index-html | ||
path: index.html | ||
|
||
- name: Use WebApp Console Log Action | ||
id: webapp_console_log | ||
uses: ./ | ||
with: | ||
artifact-name: index-html | ||
webapp-url: 'http://localhost' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
continue-on-error: true | ||
|
||
- name: Check previous step result and set job result | ||
if: always() | ||
run: | | ||
if [ "${{ steps.webapp_console_log.outcome }}" == "failure" ]; then | ||
echo "Previous step failed as expected, marking job as success" | ||
exit 0 | ||
else | ||
echo "Previous step did not fail, failing the job" | ||
exit 1 | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: "Negative Test - missing artifact name" | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
- closed | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
jobs: | ||
fail: | ||
runs-on: ubuntu-latest | ||
name: Should fail early - has localhost but no artifact name | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Use WebApp Console Log Action | ||
id: webapp_console_log | ||
uses: ./ | ||
with: | ||
webapp-url: 'http://localhost' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
continue-on-error: true | ||
|
||
- name: Check previous step result and set job result | ||
if: always() | ||
run: | | ||
if [ "${{ steps.webapp_console_log.outcome }}" == "failure" ]; then | ||
echo "Previous step failed as expected, marking job as success" | ||
exit 0 | ||
else | ||
echo "Previous step did not fail, failing the job" | ||
exit 1 | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
name: "Positive Test - all parameters set" | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
- closed | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
jobs: | ||
pass: | ||
runs-on: ubuntu-latest | ||
name: Should pass - has all parameters set | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Create fake App with console outputs | ||
run: | | ||
touch index.html | ||
cat > index.html << EOF | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>New Page</title> | ||
</head> | ||
<body> | ||
<h1>Hello, World!</h1> | ||
<script> | ||
console.debug('This is a debug message and likely hidden in the pass workflow'); | ||
console.info('This is an info in the pass workflow'); | ||
console.log('This is a log in the pass workflow'); | ||
console.log('This is another log in the pass workflow'); | ||
console.warn('This is a warning in the pass workflow'); | ||
console.error('This is an error in the pass workflow'); | ||
</script> | ||
</body> | ||
</html> | ||
EOF | ||
- name: Upload index.html | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: index-html | ||
path: index.html | ||
|
||
- name: Use WebApp Console Log Action | ||
uses: ./ | ||
with: | ||
artifact-name: index-html | ||
comment-tag: console-log2 | ||
headline: No emojis, min log level warning, max log level error | ||
max-log-level: error | ||
min-log-level: warning | ||
port: 3001 | ||
show-emoji: false | ||
wait-time: 5 | ||
webapp-url: 'http://localhost' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
name: "Positive Test - has localhost but no port" | ||
|
||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
- closed | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
jobs: | ||
pass: | ||
runs-on: ubuntu-latest | ||
name: Should pass - has localhost but no port | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Create fake App with console outputs | ||
run: | | ||
touch index.html | ||
cat > index.html << EOF | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>New Page</title> | ||
</head> | ||
<body> | ||
<h1>Hello, World!</h1> | ||
<script> | ||
console.debug('This is a debug message and likely hidden in the pass workflow'); | ||
console.info('This is an info in the pass workflow'); | ||
console.log('This is a log in the pass workflow'); | ||
console.log('This is another log in the pass workflow'); | ||
console.warn('This is a warning in the pass workflow'); | ||
console.error('This is an error in the pass workflow'); | ||
</script> | ||
</body> | ||
</html> | ||
EOF | ||
- name: Upload index.html | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: index-html | ||
path: index.html | ||
|
||
- name: Use WebApp Console Log Action | ||
uses: ./ | ||
with: | ||
artifact-name: index-html | ||
comment-tag: console-log3 | ||
headline: Should pass - has localhost but no port | ||
max-log-level: error | ||
min-log-level: warning | ||
wait-time: 5 | ||
webapp-url: 'http://localhost' | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,6 @@ pnpm-debug.log* | |
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
|
Oops, something went wrong.