-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Github Workflow #69
Merged
Merged
Github Workflow #69
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4d01268
ci: wiby workflow
dominykas 4046b13
ci: unpin request-action version
dominykas d1a2298
ci: refactor - extract check name
dominykas 7a4c112
ci: document installation
dominykas 649eb04
docs: add details on usage
dominykas 2fee3dd
docs: clarify access requirements
dominykas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,217 @@ | ||
name: wiby | ||
|
||
on: | ||
issue_comment: | ||
types: [ created ] | ||
|
||
env: | ||
WIBY_CHECK_NAME: "wiby" | ||
WIBY_NODE_VERSION: 14 | ||
|
||
jobs: | ||
|
||
permissions: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, 'wiby ') && (github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'COLLABORATOR') }} | ||
|
||
steps: | ||
- run: 'echo "Author association: ${{ github.event.comment.author_association }}"' | ||
|
||
test: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
needs: permissions | ||
|
||
if: ${{ startsWith(github.event.comment.body, 'wiby test') }} | ||
|
||
steps: | ||
|
||
- name: Load PR | ||
uses: octokit/[email protected] | ||
with: | ||
route: ${{ github.event.issue.pull_request.url }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
id: load_pr | ||
|
||
- name: Get PR information | ||
run: | | ||
echo "::set-output name=branch::${{ fromJson(steps.load_pr.outputs.data).head.ref }}" | ||
echo "::set-output name=head_sha::${{ fromJson(steps.load_pr.outputs.data).head.sha }}" | ||
echo "::set-output name=repo_name::${{ fromJson(steps.load_pr.outputs.data).base.repo.full_name }}" | ||
echo "::set-output name=repo_url::${{ fromJson(steps.load_pr.outputs.data).base.repo.html_url }}" | ||
id: pr | ||
|
||
- name: Set "queued" status | ||
uses: octokit/[email protected] | ||
with: | ||
route: POST /repos/:repository/check-runs | ||
repository: ${{ steps.pr.outputs.repo_name }} | ||
mediaType: | | ||
previews: | ||
- antiope | ||
name: ${{ env.WIBY_CHECK_NAME }} | ||
details_url: "${{ steps.pr.outputs.repo_url }}/actions/runs/${{ github.run_id }}" | ||
head_sha: ${{ steps.pr.outputs.head_sha }} | ||
status: "queued" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Checkout PR Branch | ||
uses: actions/checkout@v2 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
repository: ${{ steps.pr.outputs.repo_name }} | ||
ref: ${{ steps.pr.outputs.branch }} | ||
|
||
- name: Prepare Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ env.WIBY_NODE_VERSION }} | ||
|
||
- name: wiby test | ||
run: | | ||
if cat package.json | jq -e '.scripts["action-wiby-test"]'; then | ||
# this is primarily so that wiby can test itself using itself | ||
npm run action-wiby-test | ||
else | ||
npm install | ||
npx wiby test | ||
fi | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.WIBY_TOKEN }} | ||
|
||
- name: Handle errors | ||
uses: octokit/[email protected] | ||
if: ${{ failure() }} | ||
with: | ||
route: POST /repos/:repository/check-runs | ||
repository: ${{ steps.pr.outputs.repo_name }} | ||
mediaType: | | ||
previews: | ||
- antiope | ||
name: ${{ env.WIBY_CHECK_NAME }} | ||
details_url: "${{ steps.pr.outputs.repo_url }}/actions/runs/${{ github.run_id }}" | ||
head_sha: ${{ steps.pr.outputs.head_sha }} | ||
conclusion: "failure" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set "in_progress" status | ||
uses: octokit/[email protected] | ||
with: | ||
route: POST /repos/:repository/check-runs | ||
repository: ${{ steps.pr.outputs.repo_name }} | ||
mediaType: | | ||
previews: | ||
- antiope | ||
name: ${{ env.WIBY_CHECK_NAME }} | ||
details_url: "${{ steps.pr.outputs.repo_url }}/actions/runs/${{ github.run_id }}" | ||
head_sha: ${{ steps.pr.outputs.head_sha }} | ||
status: "in_progress" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
result: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
needs: permissions | ||
|
||
if: ${{ startsWith(github.event.comment.body, 'wiby result') }} | ||
|
||
steps: | ||
|
||
- name: Load PR | ||
uses: octokit/[email protected] | ||
with: | ||
route: ${{ github.event.issue.pull_request.url }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
id: load_pr | ||
|
||
- name: Get PR information | ||
run: | | ||
echo "::set-output name=branch::${{ fromJson(steps.load_pr.outputs.data).head.ref }}" | ||
echo "::set-output name=head_sha::${{ fromJson(steps.load_pr.outputs.data).head.sha }}" | ||
echo "::set-output name=repo_name::${{ fromJson(steps.load_pr.outputs.data).base.repo.full_name }}" | ||
echo "::set-output name=repo_url::${{ fromJson(steps.load_pr.outputs.data).base.repo.html_url }}" | ||
id: pr | ||
|
||
- name: Checkout PR Branch | ||
uses: actions/checkout@v2 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
repository: ${{ steps.pr.outputs.repo_name }} | ||
ref: ${{ steps.pr.outputs.branch }} | ||
|
||
- name: Prepare Node.js | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ env.WIBY_NODE_VERSION }} | ||
|
||
- name: wiby result | ||
run: | | ||
# execute wiby result and set action result | ||
|
||
handle_result() { | ||
|
||
WIBY_RESULT_CODE=$1 | ||
|
||
if [ ${WIBY_RESULT_CODE} -eq 64 ]; then | ||
echo "`wiby` exited with code 64 - results are still pending" | ||
else | ||
echo "::set-output name=wiby_conclusion::failure" | ||
fi | ||
|
||
} | ||
|
||
if cat package.json | jq -e '.scripts["action-wiby-result"]'; then | ||
# this is primarily so that wiby can test itself using itself | ||
npm run action-wiby-result || handle_result $? | ||
else | ||
npm install | ||
npx wiby result || handle_result $? | ||
fi | ||
|
||
# if we got here - there was no error | ||
echo "::set-output name=wiby_conclusion::success" | ||
|
||
env: | ||
GITHUB_TOKEN: ${{ secrets.WIBY_TOKEN }} | ||
id: wiby_result | ||
|
||
- name: Handle errors | ||
uses: octokit/[email protected] | ||
if: ${{ failure() }} | ||
with: | ||
route: POST /repos/:repository/check-runs | ||
repository: ${{ steps.pr.outputs.repo_name }} | ||
mediaType: | | ||
previews: | ||
- antiope | ||
name: ${{ env.WIBY_CHECK_NAME }} | ||
details_url: "${{ steps.pr.outputs.repo_url }}/actions/runs/${{ github.run_id }}" | ||
head_sha: ${{ steps.pr.outputs.head_sha }} | ||
conclusion: "failure" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set status from result | ||
uses: octokit/[email protected] | ||
if: ${{ steps.wiby_result.outputs.wiby_conclusion != '' }} | ||
with: | ||
route: POST /repos/:repository/check-runs | ||
repository: ${{ steps.pr.outputs.repo_name }} | ||
mediaType: | | ||
previews: | ||
- antiope | ||
name: ${{ env.WIBY_CHECK_NAME }} | ||
details_url: "${{ steps.pr.outputs.repo_url }}/actions/runs/${{ github.run_id }}" | ||
head_sha: ${{ steps.pr.outputs.head_sha }} | ||
conclusion: ${{ steps.wiby_result.outputs.wiby_conclusion }} | ||
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,31 @@ | ||
# wiby github workflow | ||
|
||
The `wiby` workflow for Github is very much work in progress, but please ask questions in the issue tracker. | ||
|
||
## Installation / Upgrading | ||
|
||
This is a manual step, until automation is ready: | ||
|
||
1. Install `wiby` as a dev dependency (and update to latest version) | ||
- having it as a dev dep is not strictly necessary, as the workflow relies on `npx wiby`, but it does give control over the installed version | ||
2. `mkdir -p .github/workflows && npm explore wiby -- cat .github/workflows/wiby.yaml > .github/workflows/wiby.yaml` | ||
- Duplicate the default `wiby` workflow - the automation, when developed, will attempt to keep it up to date at that location | ||
3. Make sure your `.github/workflows/wiby.yaml` ends up on the default (`main`, `master`) branch on Github | ||
- i.e. commit, push, open a PR and merge it, if necessary | ||
4. Add a `WIBY_TOKEN` secret | ||
- create a new one at https://github.com/settings/tokens, required scopes: `repo:status` and `public_repo` | ||
- the account has to have _push_ (merge access not necessary) access to the test repositories - you will probably want to fork the dependents into that account (or a separate organization) | ||
- you may want to use a robot account which _does not have **any** merge access_, as Github does not allow restricting tokens to a subset of repositories | ||
- the bot account does not need to have access to the original repository (only to the forks used for testing) | ||
|
||
|
||
## Usage | ||
|
||
0. This assumes `.wiby.json` is already configured and that you're an owner or a contributor on the dependency repo | ||
1. Open a PR against the dependency repository | ||
2. Post a comment saying `wiby test` in the PR | ||
- This should kick off the test workflow and update the `package.json` of configured dependents | ||
- Shortly after that, a `wiby` status check will have its status set to `pending` | ||
3. Wait a reasonable amount of time for the dependents to finish their tests | ||
4. Post a comment saying `wiby result` | ||
- Shortly after that, the `wiby` status check will changes its status to report the results of the tests in the dependents (but it may stay pending if they're still running) |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should be a label instead? It’s cleaner and only permissioned people can do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue with the label is that it's unclear how to re-run the job. Remove the label and add it again? Automatically remove the label on new push or when the job succeeds?
And there's still the need to
wiby results
... (which could alternatively be achieved with scheduled builds or smth)Happy to iterate on this in the upcoming versions - would like to get this into some real life usage though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Starting the job would remove the label, so you'd just "add the label".
I also think that posting the results should be automatic, in a single updated-in-place comment, rather than requested (like codecov results, for example)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be automatic, yes, but there is no simple way to achieve it with what is available. Ideally you'd be able to schedule a job or to have a sleep routine which doesn't count against your minutes, but short of that - there's a significant amount of work needed, hence why I started with a comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, gotcha. (either way this is fine for now, just offering thoughts)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, ideas most welcome.