Adds info/changes for local action testing#46
Conversation
interstateone
left a comment
There was a problem hiding this comment.
I'm really glad that you figured out how to get act working, this will make the feedback cycle during development a lot shorter. I have a couple questions about these changes first but they're definitely a step in the right direction.
actiontest/readme.md
Outdated
| @@ -0,0 +1,11 @@ | |||
| To run locally. | |||
|
|
|||
| 1. Install ACT - https://github.com/nektos/act | |||
There was a problem hiding this comment.
You'll also need Docker Desktop on macOS installed and running. I know this might seem obvious but I didn't have it running, and in this case act just fails with zero output which is a bit mystifying.
actiontest/readme.md
Outdated
| To run locally. | ||
|
|
||
| 1. Install ACT - https://github.com/nektos/act | ||
| 2. RUN: act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 -j testLocal --secret-file actiontest/.secrets --env-file actiontest/.env |
There was a problem hiding this comment.
| 2. RUN: act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 -j testLocal --secret-file actiontest/.secrets --env-file actiontest/.env | |
| 2. RUN: act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 -j test --secret-file actiontest/.secrets --env-file actiontest/.env |
I think this needs to change to be test to match the job name in test.yml, does that seem right or was this testLocal for another reason?
There was a problem hiding this comment.
Thanks.. originally I had a separate workflow for testing locally (testLocal) this will become test
actiontest/readme.md
Outdated
| Couple of things: | ||
|
|
||
| - need to use the `ubuntu-latest=nektos/act-environments-ubuntu:18.04` docker image which is 18 GB! | ||
| - `test` - the name of your job from the test.yml |
There was a problem hiding this comment.
| - `test` - the name of your job from the test.yml | |
| - `test` - the name of your job from the .github/workflows/test.yml file. |
actiontest/action.yml
Outdated
| @@ -0,0 +1,28 @@ | |||
| name: '1Password Secrets' | |||
There was a problem hiding this comment.
Do we need this file? I'm not sure I understand how it ends up being used if we do, because it's not directly referenced by the act command in the README. I'd prefer to use the one in the root in the repo instead of duplicating it, but I'm not sure if that's possible.
There was a problem hiding this comment.
So I could not get act to work properly using the regular action file and the regular test.yml
If you try to run the regular test.yml step that runs on github you'll get a
| Error: Cannot find module '/github/workspace/1password-action/dist/index.js'
Lots of people are having the same issue: nektos/act#391, nektos/act#185
Looks like an issue with the path when it copies. I tried a bunch of things, but one suggestion was to make a copy of your action.yml pointing it to '../dist/index.js' instead. This seemed to work.
There was a problem hiding this comment.
I encountered this same problem and got to this PR from a reference in nektos/act#185. This file is not needed (we were doing the same). What needs to happen is that the action needs to add the location path to the checkout. Since the test action is using ./ then checkout path would be: path: "1password-action"
.github/workflows/test.yml
Outdated
| - name: Test Action - local | ||
| if: ${{ env.ACT }} | ||
| uses: ./actiontest | ||
| id: secretsLocal |
There was a problem hiding this comment.
Since we're assuming that only one of these Test Action steps ever runs, does this work if they both have the same step ID, and then we would only need the one verify step below?
There was a problem hiding this comment.
alas, you would think, but I was getting errors when I had the same id on multiple steps. This may work on github runner but didn't seem to work on docker.
.gitignore
Outdated
| lib/**/* | ||
|
|
||
| # For local action testing, these hold the secrets needed for testing. | ||
| actiontest/.secrets |
.github/workflows/test.yml
Outdated
| - uses: ./ | ||
| - name: Test Action - local | ||
| if: ${{ env.ACT }} | ||
| uses: ./actiontest |
There was a problem hiding this comment.
this would need to change to:
| uses: ./actiontest | |
| uses: ./ |
.github/workflows/test.yml
Outdated
| @@ -22,7 +22,23 @@ jobs: | |||
| runs-on: ${{ matrix.runs-on }} | |||
| steps: | |||
| - uses: actions/checkout@v2 | |||
There was a problem hiding this comment.
| - uses: actions/checkout@v2 | |
| - uses: actions/checkout@v2 | |
| with: | |
| path: "1password-action" |
|
@alfredodeza Thank you very much for the direction! 🙇 That simplifies things alot! |
interstateone
left a comment
There was a problem hiding this comment.
This works really well, thanks Matt!
One last question about file organization in the repo but otherwise good to 🚢
package.json
Outdated
| "description": "TypeScript template action", | ||
| "main": "lib/main.js", | ||
| "scripts": { | ||
| "act": "act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 -j test --secret-file actiontest/.secrets --env-file actiontest/.environment", |
There was a problem hiding this comment.
Good idea to add this here
actiontest/readme.md
Outdated
| 1. Install Docker Desktop https://www.docker.com/products/docker-desktop | ||
| 2. Install ACT - https://github.com/nektos/act | ||
| 3. RUN: act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 -j test --secret-file actiontest/.secrets --env-file actiontest/.environment |
There was a problem hiding this comment.
| 1. Install Docker Desktop https://www.docker.com/products/docker-desktop | |
| 2. Install ACT - https://github.com/nektos/act | |
| 3. RUN: act -P ubuntu-latest=nektos/act-environments-ubuntu:18.04 -j test --secret-file actiontest/.secrets --env-file actiontest/.environment | |
| 1. Install Docker Desktop https://www.docker.com/products/docker-desktop | |
| 1. Install ACT - https://github.com/nektos/act | |
| 1. Copy .secrets-example to .secrets and replace `xxxx` with real values | |
| 1. Run `npm run act` |
Adds the secrets step and prefer the act script. Also switched to let markdown rendering do the numbering correctly, which is a personal preference, because I find it makes it easier to edit later.
actiontest/readme.md
Outdated
| @@ -0,0 +1,12 @@ | |||
| To run locally. | |||
There was a problem hiding this comment.
I wonder if we could remove this directory and have its contents in the root, and part of the reason for that is the root README.md has a Development heading, where these steps might be more easily discoverable. If we do this we'll also need to update the .gitignore with the new secrets path.
Closes #45
Makes some changes so that we can test locally with ACT - https://github.com/nektos/act
Made a readme in actiontest/readme.md for more information.
Makes input values as secret so they can't be leaked to github console.