⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 22, 2025

Add tests for github/release action

  • Create test directory structure: gh-actions/github/release/tests/
  • Create mock gh command that can:
    • Record all calls to a file
    • Mock only gh release view and gh release create (commands used by release.sh)
    • Respond to gh release view based on environment variable
    • Respond to gh release create with success
  • Create mock git command that can:
    • Mock only git commit and git push (commands used by release.sh)
    • Record all calls to a file
    • Pass verification without needing real git operations
  • Create test cases (success paths only):
    • Test 1: New release with dry-run=true (verifies dry-run path)
    • Test 2: New release with dry-run=false (verifies real release path)
    • Test 3: Release already exists with fail-if-exists=false (verifies warning path)
  • Use GITHUB_ENV to properly propagate mock environment variables
  • Inject mock PATH via GITHUB_PATH in before step
  • Apply version JSON format fix to all tests
  • Remove unnecessary comments and whitespace
  • Minimal test setup (no unnecessary git commands since git is mocked)
  • Simplify mocks to only mock commands actually used by release.sh
  • Tests ready for CI execution
Original prompt

this is a more complicated task - hope you are up to it

we have recently added a release action gh-actions/github/release (for example usage see the _publish workflow)

we have also recently added a test framework for actions (files are in gh-actions and named *.test.yml)

i would like you to add some tests for github/release

ideally they exercise all/most code paths and validate events correctly

i think the easiest way to do this will be to mock the gh action by overriding it in path (eg adding /usr/local/bin/mocks to path and adding there)

the mock will need to record calls and respond according to what args it was called with and i reckon for some cases env vars to respond differently - eg to simulate different potential responses)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@netlify
Copy link

netlify bot commented Dec 22, 2025

Deploy Preview for nifty-bassi-e26446 ready!

Name Link
🔨 Latest commit e4a05a2
🔍 Latest deploy log https://app.netlify.com/projects/nifty-bassi-e26446/deploys/6948a0a67403920007ae7c36
😎 Deploy Preview https://deploy-preview-3173--nifty-bassi-e26446.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI changed the title [WIP] Add tests for github release action Add tests for github/release action with mocked gh and git commands Dec 22, 2025
Copilot AI requested a review from phlax December 22, 2025 00:50
@phlax
Copy link
Member

phlax commented Dec 22, 2025

@copilot ```console
Getting action download info
Download action repository 'envoyproxy/[email protected]' (SHA:b8d8689b77148bc7377e9f314e081ae3434ebf05)
Run ./gh-actions/github/release
Run 4db1102
Run # Create temporary script file
Run envoyproxy/toolshed/gh-actions/[email protected]
Error: Child process exited with code 3
Error: Error: Command failed: cat /tmp/tmp-2167-4AuOgTWR7mbn | jq -r -L /home/runner/work/_actions/envoyproxy/toolshed/actions-v0.3.35/gh-actions/jq/modules -f /tmp/tmp-2167-nKkV20Vet2aS
jq: error: syntax error, unexpected '$', expecting end of file (Unix shell quoting issues?) at , line 13:
| "export PATH="${GITHUB_WORKSPACE}/gh-actions/github/release/tests/mocks:$PATH"
jq: 1 compile error

Copy link
Contributor Author

Copilot AI commented Dec 22, 2025

@copilot ```console
Getting action download info
Download action repository 'envoyproxy/[email protected]' (SHA:b8d8689b77148bc7377e9f314e081ae3434ebf05)...

Fixed in a2af1ea. The issue was using ${GITHUB_WORKSPACE} in the template-release string which goes through jq processing. Changed to $(pwd) which resolves correctly in the bash context.

Signed-off-by: Ryan Northey <[email protected]>
@phlax phlax force-pushed the copilot/add-tests-for-github-release branch from 76efd0c to e7b8de5 Compare December 22, 2025 01:07
@phlax
Copy link
Member

phlax commented Dec 22, 2025

@copilot if you look - ive fixed the dry-run test so it now passes - please fix the others

Copy link
Contributor Author

Copilot AI commented Dec 22, 2025

@copilot if you look - ive fixed the dry-run test so it now passes - please fix the others

Fixed in 37ce53a. Applied the same version JSON format fix ({"version": "1.2.3", "next": "..."}) to both exists-warn and real-release tests, and removed unnecessary comments and whitespace as requested.

@phlax
Copy link
Member

phlax commented Dec 22, 2025

@copilot wtf is this

git init --initial-branch=main
git config user.email "[email protected]"
git config user.name "Test User"

echo "1.2.3-dev" > /tmp/test-version-real.txt
git add /tmp/test-version-real.txt
git commit -m "Initial commit"

rm -f /tmp/gh-mock-real.log
rm -f /tmp/git-mock-real.log

if git is mocked we dont need any of that

Copy link
Contributor Author

Copilot AI commented Dec 22, 2025

@copilot wtf is this

git init --initial-branch=main...

Fixed in 039b8ec. Removed all unnecessary git commands from the test setup sections since git is mocked. Now only creates the directory, version file, and cleans up logs.

@phlax
Copy link
Member

phlax commented Dec 22, 2025

@copilot looking at the mocks they are mocking sub/commands that are not currently used - as this is just for these tests it should only mock the things that are needed

Copy link
Contributor Author

Copilot AI commented Dec 22, 2025

@copilot looking at the mocks they are mocking sub/commands that are not currently used - as this is just for these tests it should only mock the things that are needed

Fixed in 04bd3e9. Simplified mocks to only handle commands actually used by release.sh:

  • gh: only release view and release create
  • git: only commit and push

Also removed template-release override - now using env vars to configure mocks and injecting PATH via GITHUB_PATH in the before step to test the actual template-release behavior.

@phlax
Copy link
Member

phlax commented Dec 22, 2025

@copilot warn test


$ git push origin refs/heads/main
To mock-origin
   abc123..def456  main -> main
✗ Error: Expected 'gh release view' in output

other 2

 $ git push origin refs/heads/main
To mock-origin
   abc123..def456  main -> main
✓ Found 'gh release create' command in output
✓ No 'SKIPPED' marker found (real release executed)
✓ Found release URL in output
✗ Error: Mock log file not found
Error: Process completed with exit code 1.

Copy link
Contributor Author

Copilot AI commented Dec 22, 2025

@copilot warn test

Fixed in e4a05a2. The environment variables weren't being propagated correctly. Changed from using step-level env: to writing to $GITHUB_ENV in the before step, which properly sets environment variables that persist to subsequent steps including the nested composite action.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants