-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add various simplifications and more robust GitHub actions for the ch…
…eck-in test (#225) Minor GitHub action changes. The biggest one is that we have verified that the Gradle caches work between steps, branches and jobs, so nothing building close in time cannot overwrite the GitHub workflow caches for another commit. We also make sure that all installDist/manualTest verification for the test platforms is finished before trying to publish a snapshot artifact. This is to make sure that even if we run on the publishing platform (ubuntu-latest), and windows fails, we do not publish anything that may be a windows-breaker. This is all good prep work for the jreleaser configuration which will accept an uploaded build artifact blob consisting of the installWithLaunchersDist destination directories after uploadArtifact. We have also added various cleaners that are meant to run either manually dispatched, and on a cron schedule, so that we keep the number of published snapshots low, with only the ~10 latest ones for the same version. Furthermore we may want to delete old caches for old runs, as well as workflow results, when they cease to be relevant.
- Loading branch information
Showing
4 changed files
with
191 additions
and
22 deletions.
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,115 @@ | ||
|
||
# | ||
# This is a workflow that is meant to keep our temporary data in check on the server side: | ||
# | ||
# Things we want to make sure stay within bounds are: | ||
# | ||
# * GitHub Action caches, especially for Java distribution and Gradle. | ||
# | ||
# * Snapshot publications. GitHub handles SNAPSHOTS in a non standard way, so it's not possible to just | ||
# enumerate all versions of a SNAPSHOT package, which of course is wrong, according to the Maven | ||
# specification. But since every new commit to master will publish a new platform release, it quickly | ||
# gets uwieldy to keep all those around. We should at most retain maybe the last ~10 commits' worth | ||
# of snapshot publications, or something like that. | ||
# | ||
# * Finished workflows (at least those that have been successful) after a certain number of days. | ||
# Now we just fill up the disk until we hit the GitHub free quota, which is unnecessary, and | ||
# possibly a security hazard if some zero day exploit thing appears, and we happen to have some | ||
# finished workflow that we have forgotten about that printed secrets to the console or something. | ||
# | ||
|
||
name: XDK GitHub Actions Cleaner | ||
on: | ||
# | ||
# Set up a periodic cron schedule for this task to make sure cache build-up is curbed. | ||
# We also have a workflow_dispatch mechanism, so that the job can easily be triggered manually from | ||
# the GitHub CLI command "gh", and through the GUI for the GitHub Actions workflow on github.com. | ||
# | ||
# The cron syntax is "minute (0-59), hour (0-23), day (1-31), month (1-12), day of week (0-6) | ||
# For example: "0 13 * * 1" means "every Monday at 1PM UTC (9AM EST, 2PM CEST)" | ||
# | ||
# There is also an "every X" syntax for intervals. | ||
# For example: "*/10 * * * *" means "do something every 10 minutes") | ||
# | ||
# We do the cache cleanup once a week, at midnight UTC. We may want to adjust later. | ||
# | ||
|
||
# TODO: Enable as soon as we have a test environment after first merge. | ||
#schedule: | ||
# - cron: "0 0 * * 1" | ||
|
||
# | ||
# Allow manual dispatch of this cleanup job from GitHub website under the XVM repository | ||
# Actions tab, as well as from the GitHub CLI and/or the REST API. | ||
# | ||
workflow_dispatch: | ||
dry_run: | ||
description: 'Dry run the cache and workflow cleaner' | ||
required: false | ||
default: false | ||
|
||
env: | ||
BOT_TOKEN: ${{ secrets.ORG_XTCLANG_DISCORD_BOT_TOKEN }} | ||
BOT_CHANNEL_ID: ${{ vars.ORG_XTCLANG_DISCORD_GITHUB_CHANNEL_ID }} | ||
# TODO: To get workflow dispatch to work we need to merge the branch into master. Hence, it goes it | ||
# with dry run only as its configuration | ||
DRY_RUN: true # ${{ github.event.inputs.dry_run || false }} | ||
# ACTIONS_RUNNER_DEBUG: true | ||
# ACTIONS_STEP_DEBUG: true | ||
|
||
jobs: | ||
clean-workflows: | ||
name: Delete older workflows | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: write | ||
contents: read | ||
steps: | ||
- name: Delete old workflow runs | ||
if: ${{ false }} | ||
uses: Mattraks/delete-workflow-runs@v2 | ||
with: | ||
token: ${{ github.token }} | ||
repository: ${{ github.repository }} | ||
retain_days: 30 | ||
keep_minimum_runs: 6 | ||
dry_run: ${{ env.DRY_RUN }} | ||
|
||
clean-snapshots: | ||
name: Delete old Maven snapshot packages/publications | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Delete old XDK and XTC Plugin Maven snapshot packages | ||
if: ${{ false }} | ||
uses: smartsquaregmbh/[email protected] | ||
with: | ||
organization: 'xtclang' | ||
type: 'maven' | ||
repository: 'xvm' | ||
version-pattern: '.*-SNAPSHOT$' | ||
names: | | ||
org.xtclang.xtc-plugin.org.xtclang.xtc-plugin.gradle.plugin | ||
org.xtclang.xdk | ||
org.xtclang.xtc-plugin | ||
dry_run: ${{ env.DRY_RUN }} | ||
|
||
clean-caches: | ||
name: Delete all caches | ||
runs-on: ubuntu-latest | ||
env: | ||
cron_trigger: "${{ github.event_name == 'schedule' && 'true' || 'false' }}" | ||
steps: | ||
- name: Setup cleaner | ||
if: ${{ false }} | ||
shell: bash | ||
run: | | ||
echo "Starting GitHub action cleaner for repository." | ||
echo " Reason : dispatch trigger event: ${{ github.event_name }}." | ||
echo " Dry run : run: ${{ env.cron_trigger }}." | ||
- name: List and/or clean all GitHub action caches | ||
uses: easimon/wipe-cache@main | ||
with: | ||
# TODO: Temporarily disable the cache deletion based on cron schedule, until we have verified it works manually | ||
dry-run: ${{ env.DRY_RUN }} | ||
github-token: ${{ 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
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
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