-
Notifications
You must be signed in to change notification settings - Fork 37
GitHub actions cleanup #76
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
Conversation
Remove redundant test step from release workflow. Modify test workflow concurrency to cancel jobs that have a subsequent one queued to reduce load on the runners. Remove all permissions for the workflows by default. Change caching to only cache dependencies from the master branch. Still restore dependencies on PRs from the master branch cache.
@@ -1,9 +1,12 @@ | |||
name: Make release | |||
|
|||
permissions: { } |
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.
Improve security by not using default permissions.
java-version: 8 | ||
distribution: 'temurin' | ||
- name: Cache Maven packages | ||
- name: Cache and restore Maven packages on master |
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 cache and restore followed by the restore on PR section is a bit redundant because this workflow only runs on the master branch. So, it should really only need this step without the if check. However, I think it's safer to keep it as is. Keeping it as is doesn't harm anything, it is a bit more complicated to read though.
- name: Build | ||
run: mvn clean verify | ||
|
||
test: |
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.
mvn clean verify
already runs tests. This step is redundant. The only difference is that install
isn't executed anymore. I don't expect that to be an issue though, unless the publish step requires an install to happen first.
|
||
- name: Publish package | ||
run: mvn -DskipTests=true --batch-mode -P ossrh-publish -Dgpg.passphrase=${{ secrets.ORG_GPG_PASSPHRASE }} deploy | ||
run: mvn -Dmaven.test.skip=true --batch-mode -P ossrh-publish -Dgpg.passphrase=${{ secrets.ORG_GPG_PASSPHRASE }} deploy |
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.
-Dmaven.test.skip=true
will skip compiling and executing tests. -DskipTests=true
only skips executing tests.
- master | ||
pull_request: | ||
|
||
concurrency: |
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.
If the group
matches, then cancel the existing workflow run and start a new one. Essentially, if you have a PR that is running a workflow and you push another change to it then the existing run will be cancelled and a new one started. This saves on some CI usage.
java-version: 8 | ||
distribution: 'temurin' | ||
- name: Cache Maven packages | ||
- name: Cache and restore Maven packages on master |
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.
PRs might contain various dependency changes that aren't always desired in the cache. So, only write to the cache from the master branch.
PRs will still restore from the master branch, so only dependency changes within that PR need to be downloaded.
- master | ||
|
||
jobs: | ||
build: |
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.
Since you removed all permissions, you have to add the contents: read
permission to this job.
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 seemed odd to me that I didn’t add any permissions back, but I didn’t see anything in the action I was referencing either.
I’ll check again and update. Same for the other file.
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.
Apperently, I was wrong. I always thought the contents: read
permission was necessary for actions to get the repo content.
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.
I’m not really sure why, I’m just glad it works.
cancel-in-progress: true | ||
|
||
jobs: | ||
test: |
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 job also needs the contents: read
permission.
Remove redundant test step from release workflow.
Modify test workflow concurrency to cancel jobs that have a subsequent one queued to reduce load on the runners.
Remove all permissions for the workflows by default.
Change caching to only cache dependencies from the master branch. Still restore dependencies on PRs from the master branch cache.