Skip to content
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

ci: Use pointer workflows to preserve run date #1468

Merged
merged 1 commit into from
Jan 10, 2021

Conversation

pawelpasterz
Copy link
Contributor

@pawelpasterz pawelpasterz commented Jan 7, 2021

Due to GH API limitation workflow is unable to fetch info about itself. Dates of previous runs are used in scripts. An empty array is returned instead.
As a workaround to overcome those limitations two new workflows are introduced.
Their intention is "just to be triggered" and therefore preserve the date which is used in dependencies and IT workflows.

Test Plan

How do we know the code works?

There is no easy way to test the implementation. This PR introduced 2 new workflows which can be triggered after the merge to master.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2021

CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅

@github-actions
Copy link
Contributor

github-actions bot commented Jan 7, 2021

Timestamp: 2021-01-07 13:22:51
Buildscan url for ubuntu-workflow run 468964713

@pawelpasterz pawelpasterz force-pushed the add-workflow-pointers branch from 2c4cebc to ebb23c9 Compare January 7, 2021 13:18
@pawelpasterz
Copy link
Contributor Author

recheck

@pawelpasterz pawelpasterz marked this pull request as ready for review January 7, 2021 14:25
runs-on: ubuntu-latest
steps:
- run: |
echo "Integration tests pointer updated: $(date +'%Y-%m-%d')"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how is it exactly preserving the date via an echo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... I thought the description is just enough. Maybe I should add additional info...
Long story short, let's say we have workflow described in a.yml. During a run we want to fetch some data about previous a runs (like a time when it was previously finished). We use https://docs.github.com/en/free-pro-team@latest/rest/reference/actions#list-workflow-runs. Due to limitations, we get an empty array as a response.
But we can use the same endpoint to get info about another workflow (so inside a workflow we can get info about b). Those pointers are "just to be triggered" meaning they do nothing like preserves (by being triggered) timestamp, date etc.
For dependency update workflow looks like:

  1. start dependency update workflow
  2. proceed with all the jobs/steps but in parallel trigger (with repository dispatch) event "pointer" workflow
  3. next time dependency update will be launched it will look for the latest date of "pointer" workflow (because it can not fetch data about itself)

how is it exactly preserving the date via an echo?

Echo is just for debugging purposes. It could be nothing there actually

id: generate-token
with:
app_id: ${{ secrets.FLANK_RELEASE_APP_ID }}
private_key: ${{ secrets.FLANK_RELEASE_PRIVATE_KEY }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I truly get nervous about sharing private keys with opensource repositories.
Are we sure its trusted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alternative is to create PAT and add it to secret. We use this logic in a couple of places inside the project. Actually, @piotradamczyk5 has configured this app and may has more detailed info

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the most popular workflow for this purpose and this is secure.
Github apps are better to manage than PAT, so that's the reason why we use them

runs-on: ubuntu-latest
steps:
- run: |
echo "Dependencies pointer updated: $(date +'%Y-%m-%d')"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really need an explanation here 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -28,7 +28,7 @@ shadowJar.apply {
}
}
// <breaking change>.<feature added>.<fix/minor change>
version = "1.3.2"
version = "1.3.3"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm check if this is not the same on develop

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, it wasn't but the master is changing all the time, will update it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm...master is still having 1.3.2 (for now at least)

@pawelpasterz pawelpasterz requested a review from Sloox January 8, 2021 15:09
Copy link
Contributor

@jan-goral jan-goral left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our CI is going to be a complicated system. I am not talking only about the impact of this PR. So you know what I mean. Will be helpful to have a documentation page for each workflow, with the described purpose and results.

@piotradamczyk5
Copy link
Contributor

Our CI is going to be a complicated system. I am not talking only about the impact of this PR. So you know what I mean. Will be helpful to have a documentation page for each workflow, with the described purpose and results.

good point maybe let's create ticket for it

@pawelpasterz pawelpasterz merged commit fac9a5c into master Jan 10, 2021
@pawelpasterz pawelpasterz deleted the add-workflow-pointers branch January 10, 2021 05:53
@github-actions github-actions bot locked and limited conversation to collaborators Jan 10, 2021
@zuziaka zuziaka added this to the Sprint -1 milestone Jan 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants