-
Notifications
You must be signed in to change notification settings - Fork 69
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
Automatically compile/generate output artifacts on push to main
#2181
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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,92 @@ | ||
name: Generate Output | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'main' | ||
- '7.17' | ||
- '8.[0-9]+' | ||
|
||
# For debugging purposes: | ||
# pull_request: | ||
# types: [opened, synchronize, reopened] | ||
# branches: | ||
# - main | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: false | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
if: github.repository_owner == 'elastic' && github.actor != 'elasticmachine' | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.PAT }} | ||
persist-credentials: true | ||
|
||
- name: Setup Node 16.x | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16.x | ||
cache: npm | ||
cache-dependency-path: '**/package-lock.json' | ||
|
||
- name: Setup Dependencies | ||
run: | | ||
make setup | ||
- name: Generate Output | ||
run: | | ||
make compile | ||
make generate | ||
- name: Check for Changed Files | ||
id: changes | ||
run: | | ||
if [ -n "$(git status --porcelain)" ]; then | ||
echo "has-changes=1" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Set Git Identity | ||
if: steps.changes.outputs.has-changes == '1' | ||
run: |- | ||
git config --global user.email "elasticmachine@users.noreply.github.com" | ||
git config --global user.name "Elastic Machine" | ||
- name: Push Output | ||
if: steps.changes.outputs.has-changes == '1' | ||
run: | | ||
cd ./output | ||
git add -A | ||
git commit -m "Update specification output" | ||
git status | ||
git push | ||
# For debugging purposes: | ||
# - name: Push Output | ||
# if: steps.changes.outputs.has-changes == '1' | ||
# env: | ||
# BRANCH_NAME: output_${{ github.run_id }}_${{ github.run_attempt }} | ||
# run: | | ||
# cd ./output | ||
|
||
# git fetch | ||
# git switch main | ||
|
||
# git add -A | ||
# git commit -m "Update specification output" | ||
|
||
# git status | ||
|
||
# git push origin HEAD:refs/heads/${{ env.BRANCH_NAME }} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.
The
make contrib
target does a few more things, such as checking licenses, running a linter, fixing the format, and also generating the typescript version.Having an action change the source code is not common and we may consider that part (code formatting) as a check, but in this particular case I think it can actually help "casual" contributors to easily contribute to the spec. So we may even go further and replace e.g. the
licence-check
called bymake contrib
withlicense-add
.Finally, what about adding a new make target that does all this so that this action only calls that single target? This may ease maintenance.
I'll let @picandocodigo look a the GitHub machinery around this.
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.
This new workflow only runs on pushes to
main
. Direct pushes should never occur due to branch protection, which means that all these checks have already run as part of the PR checks and review process.👍
I'm not sure if we should automatically modify non-generated files in general, but it's surely something to think about. On the other hand, pasting a license text is probably pretty straightforward and does not require e.g. NodeJS on the dev machine like for the compilation/generation.
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.
Oh, I missed that part! So this means PRs still need to pass the linter and license checks, and indeed we just need to addresses the compilation part here.
Note: if we don't include this on version branches (currently
8.[0-9]+
and7.17
), we should keep the current behavior (fail a PR's check if compilation changes the output): we occasionally have to backport manually, and the cause is most often a merge conflict onschema.json
.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.
Ouch, good point! I forgot about the backports in general. I think we just have to make sure this workflow runs for the version branches as well and we should be fine.