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

feat: create nightly builds #369

Merged
merged 36 commits into from
Aug 3, 2021
Merged

feat: create nightly builds #369

merged 36 commits into from
Aug 3, 2021

Conversation

iand
Copy link
Contributor

@iand iand commented Jul 22, 2021

Closes #363

⚠️ Merge this after #367

High level summary

Build scripts changes

  • ./dist.sh add-version <dist> nightly will add a nightly version to the versions file using the current date (@lidel is this still useful?)
  • make nightly add a nightly version to every dist versions file using the current date
    • one can also cd dists/<package> && make nightly to add it only to specific package - we use it on CI to run builds in paralllel (@lidel)
  • make dist will build nightly versions by checking out the latest version of the default branch and producing a build artifact named using the pattern nightly-yyyy-mm-dd-hash where hash is the starting 7 (at least) characters of the commit hash. It may be more than 7 if a shorter length would be ambiguous.
  • make all_dists is unchanged but will build a nightly version in the course of running make dist above
  • It's not expected that the nightly-yyyy-mm-dd version will be committed to the repo. It's an ephemeral version that is generated to produce a nightly build.
  • The final versions file is normally added to ipfs my make publish. This will now include the most recent nightly version. This allows the build system to ignore it on subsequent runs until a new day is reached.

TODO

  • wire up ability to build nightly-* versions using existing make publish pipeline (@iand)
  • add publish step to nightly.yml (@iand)
  • do not pollute ./nightly (@lidel)
  • ensure build does not use commits older than the nightly threshold (@lidel)
    TODO: explore checking out the last commit in the default branch before arbitrary date: git rev-list -1 --first-parent --before="2021-07-27" "$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')" – makes nightlies more deterministic (at the revision level)
  • fix vtag releases (like fs-repo-migrations/fs-repo-0-to-1) (@lidel)
  • share build scripts with main.yml (@lidel)
  • refactor to include signing (or make part of main.yml

common.mk Outdated Show resolved Hide resolved
dist.sh Outdated Show resolved Hide resolved
@ipfs ipfs deleted a comment from welcome bot Jul 22, 2021
.github/workflows/nightly.yml Outdated Show resolved Hide resolved
@iand
Copy link
Contributor Author

iand commented Jul 22, 2021

This doesn't handle any specific publishing logic for nightlies. I haven't tested but I expect that one nightly build for each day will be published.

How do we want to handle clean up of old nightlies? What is the best mechanism for keeping track of how many nightlies have been built so we can restrict to a given number, e.g. 7.

@lidel
Copy link
Member

lidel commented Jul 22, 2021

Number of nightlies per package can be calculated by grep nightly ./dists/{name}/versions | wc -l

I imagine dropping of the oldest nightlies over the limit could happen in scripts/patch.js (executed during make publish) after everything is patched, but right before returning the final CID.

@BigLep BigLep linked an issue Jul 23, 2021 that may be closed by this pull request
13 tasks
@iand
Copy link
Contributor Author

iand commented Jul 23, 2021

Number of nightlies per package can be calculated by grep nightly ./dists/{name}/versions | wc -l

No, since versions will contain only the most recent nightly since the nightly CI does not commit updates to the versions file back to the repo. See 4th bullet in the pr description.

I think the simplest place to do it is in build-go.sh as an additional step (5) in the existing sequence:

  1. check out repo ,dists/{name}/versions just contains tagged versions
  2. append nightly version to dists/{name}/versions
  3. compare with /ipfs/Qm.../{name}/versions and build anything new
  4. copy dists/{name}/versions to releases/{name}/versions
  5. append nightly builds from /ipfs/Qm.../{name}/versions to releases/{name}/versions (keeping 7)
  6. publish releases/{name}/versions as /ipfs/Qm.../{name}/versions which will now contain tagged versions and 7 nightly

I imagine dropping of the oldest nightlies over the limit could happen in scripts/patch.js (executed during make publish) after everything is patched, but right before returning the final CID.

@iand iand marked this pull request as ready for review July 26, 2021 09:51
@iand iand requested a review from lidel July 26, 2021 10:04
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

Works as expected, thank you, @iand! 🙌


I will take this over and tweak it a bit to be compatible with final approach from #367
(will comment when ready)

@lidel lidel self-assigned this Jul 27, 2021
This ensures that "nightly-2020-01-01" won't have any commits that
happened on "2020-01-02" – enabling us to build historical nightlies.
@lidel lidel changed the base branch from master to feat/signed-ci-build July 28, 2021 15:45
this makes nightly do exactly what release build does, but allows us
to tweak some behaviors, for example do pins that expires after 7 days,
or report each preview separately
This runs cleanup only when we have anything to clean up
@lidel lidel force-pushed the feat/issue-363-nightlies branch 12 times, most recently from ae80100 to db09ba3 Compare July 29, 2021 02:54
@lidel
Copy link
Member

lidel commented Jul 29, 2021

Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

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

Ready for review.

Comment on lines 3 to 8
on:
push:
## Allow manual invocation
#workflow_dispatch:
#schedule:
# - cron: '0 5 * * *' # UTC
Copy link
Member

Choose a reason for hiding this comment

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

ℹ️ we will remove push and restore schedule for cron trigger + workflow_dispatch for running nightly builds on-demand

- run: cd ./dists/${{ matrix.dist_name }} && make nightly
- run: ./dockerized make publish
- name: Create issue if build failed
uses: actions/github-script@v4
Copy link
Member

Choose a reason for hiding this comment

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

ℹ️ Third-party turn-key solutions exists, but I decided to give actions/github-script a try. It is an official action provided by GitHub, provides JS porcelain for running arbitrary API calls.

Debugging is a bit painful, but being written in JS could make it more dev friendly than bash+curl, allowing more people to maintain/extend. actions/github-script is extremely powerful, only caveat is that it needs a personal access token to do anything outside the current repo.

We may leverage it even more for developer flow automation tailored to our needs. For example, it could automatically create/label issues and add them to specific column in specific project.

env:
PIN_CID: ${{ steps.cid-reader.outputs.CID }}
PIN_NAME: "ipfs/distributions/nightly/${{ matrix.dist_name }}"
PIN_ADD_EXTRA_ARGS: "--expire-in 168h"
Copy link
Member

Choose a reason for hiding this comment

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

ℹ️ this pins nightly artifacts only for a week

Copy link
Contributor

@BigLep BigLep left a comment

Choose a reason for hiding this comment

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

Great work!
One small idea is to consider the comments you left in the PR to inline them into the code for discoverability.

Base automatically changed from feat/signed-ci-build to master August 3, 2021 22:44
@lidel lidel merged commit 55b8923 into master Aug 3, 2021
@lidel lidel deleted the feat/issue-363-nightlies branch August 3, 2021 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create nightly builds
3 participants