-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapt Holonix automation to this repo
- Loading branch information
1 parent
218faa5
commit 58ba7b5
Showing
5 changed files
with
222 additions
and
76 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,79 @@ | ||
name: "Holonix cache" | ||
|
||
on: | ||
# Assume pushes to these branches imply changes that should be cached. If not then the workflow run will be | ||
# idempotent, so it won't do any harm. | ||
push: | ||
branches: | ||
- develop | ||
- main | ||
- main-0.2 | ||
- main-0.3 | ||
# Because other things use the same cache, run once a day to make sure that the cache is up to date. | ||
schedule: | ||
- cron: "@daily" # run once a day | ||
# Allow the cache update to be run manually. | ||
workflow_dispatch: | ||
inputs: {} | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref_name }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
# ensures the cache is regularly updated for the supported versions on multiple platforms | ||
cache-update: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
target: | ||
- "github:holochain/holochain#packages.{0}.build-holonix-tests-integration" | ||
- "github:holochain/holochain#devShells.{0}.holonix" | ||
extra_args: | ||
- "" | ||
- "--refresh --override-input versions github:holochain/holochain?dir=versions/0_2" | ||
- "--refresh --override-input versions github:holochain/holochain?dir=versions/0_2_rc" | ||
- "--refresh --override-input versions github:holochain/holochain?dir=versions/0_3_rc" | ||
- "--refresh --override-input versions github:holochain/holochain?dir=versions/weekly" | ||
platform: | ||
- x86_64-darwin | ||
- aarch64-darwin | ||
- x86_64-linux | ||
os: [ ubuntu-latest, macos-latest, macos-13 ] | ||
branch: [ main, main-0.2, main-0.3 ] | ||
|
||
runs-on: [self-hosted, multi-arch] | ||
steps: | ||
- name: Print matrix | ||
env: | ||
MATRIX: ${{ toJSON(matrix) }} | ||
run: echo ${MATRIX} | ||
runs-on: ${{ matrix.os }} | ||
|
||
- name: "Cache packages ${{ matrix.extra_args }}" | ||
steps: | ||
- uses: cachix/install-nix-action@v27 | ||
with: | ||
install_url: https://releases.nixos.org/nix/nix-2.22.1/install | ||
- uses: cachix/cachix-action@v15 | ||
with: | ||
name: holochain-ci | ||
- name: Cache default Holonix flake on [${{ matrix.branch }}] | ||
env: | ||
NIX_CONFIG: "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" | ||
CACHIX_AUTH_TOKEN: "${{ secrets.CACHIX_AUTH_TOKEN_HOLOCHAIN_CI }}" | ||
# NIX_CONFIG: "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" | ||
CACHIX_AUTH_TOKEN: "${{ secrets.CACHIX_AUTH_TOKEN }}" | ||
run: | | ||
set -xe | ||
target=${{ matrix.target }} | ||
# Create a workspace and initialise a new default Holonix flake | ||
cd $(mktemp -d) | ||
nix flake init -t "github:holochain/holonix/${{ matrix.branch }}#holonix-default" # TODO | ||
# See https://docs.cachix.org/pushing#id1 | ||
nix develop --build -L --profile result-develop \ | ||
${{ matrix.extra_args }} \ | ||
${{ format(matrix.target, matrix.platform) }} | ||
nix develop --build -L --profile result-develop | ||
nix build -L --profile result-build \ | ||
${{ matrix.extra_args }} \ | ||
${{ format(matrix.target, matrix.platform) }} | ||
nix build -L --profile result-build | ||
# Don't exit if this fails so we can clean up the profile | ||
# Push both results to the cache | ||
for i in result-*; do | ||
cachix push holochain-ci $i || true | ||
cachix push holochain-ci $i | ||
done | ||
rm result* | ||
cache-check: | ||
needs: | ||
- cache-update | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
target: | ||
- "github:holochain/holochain#devShells.{0}.holonix" | ||
- "github:holochain/holochain#packages.{0}.hc-scaffold" | ||
extra_args: | ||
- "" | ||
- "--refresh --override-input versions github:holochain/holochain?dir=versions/0_2" | ||
- "--refresh --override-input versions github:holochain/holochain?dir=versions/0_2_rc" | ||
- "--refresh --override-input versions github:holochain/holochain?dir=versions/0_3_rc" | ||
- "--refresh --override-input versions github:holochain/holochain?dir=versions/weekly" | ||
platform: | ||
- x86_64-darwin | ||
- aarch64-darwin | ||
- x86_64-linux | ||
os: [ ubuntu-latest, macos-latest, macos-13 ] | ||
branch: [ main, main-0.2, main-0.3 ] | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: cachix/install-nix-action@v26 | ||
- uses: cachix/cachix-action@v14 | ||
- uses: cachix/install-nix-action@v27 | ||
with: | ||
install_url: https://releases.nixos.org/nix/nix-2.22.1/install | ||
- uses: cachix/cachix-action@v15 | ||
with: | ||
name: holochain-ci | ||
- name: Check the Holonix cache | ||
uses: holochain/nix-cache-check@v1 | ||
env: | ||
NIX_CONFIG: "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" | ||
# env: | ||
# NIX_CONFIG: "access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}" | ||
with: | ||
derivation: ${{ format(matrix.target, matrix.platform) }} | ||
extra_build_args: ${{ matrix.extra_args }} | ||
derivation: "github:holochain/holonix/${{ matrix.branch }}" # The default shell in the Holonix flake |
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,82 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Bump script to update the Holochain version in flake.nix | ||
# Usage: ./scripts/bump-holochain.sh [branch] [apply] | ||
# | ||
# The branch and apply arguments are only for testing. The branch can be set to any branch which would be expected to | ||
# exist in this repository and the apply argument can be set to false to prevent modifications to the flake.nix file. | ||
# | ||
# Method: | ||
# - Uses the current branch to work out what version of Holochain to look for. | ||
# - Picks a search pattern for a Holochain tag based on the branch. | ||
# - Searches for all Holochain tags and filters them by the search pattern. | ||
# - Picks the latest matching tag. | ||
# - If apply is not provided, or is true: Updates the flake.nix file to use the latest matching tag. | ||
# - If apply is not provided, or is true: Updates the flake lock to match the new flake.nix file. | ||
# - If apply is false: Prints the tag that would have been used to update the flake. | ||
|
||
set -euo pipefail | ||
|
||
cd "$(git rev-parse --show-toplevel)" | ||
|
||
if [ ! -f "./flake.nix" ]; then | ||
echo "File not found: ./flake.nix" | ||
exit 1 | ||
fi | ||
|
||
CURRENT_BRANCH=${1:-$(git branch --show-current)} | ||
|
||
SEARCH_PATTERN="no-tag" | ||
case $CURRENT_BRANCH in | ||
main) | ||
SEARCH_PATTERN="^holochain-0.4.[0-9]+-dev.[0-9]+$" | ||
;; | ||
main-*-rc) | ||
VERSION_STR=$(echo "$CURRENT_BRANCH" | awk -F '-' '{print $2}') | ||
|
||
# Protect against this code trying to bump 1.2.3 versions if one of those shows up. | ||
SEP_COUNT=$(echo "$VERSION_STR" | tr -d -c '.' | awk '{ print length; }') | ||
if [ "$SEP_COUNT" -ne "1" ]; then | ||
echo "Invalid version format: $VERSION_STR" | ||
exit 1 | ||
fi | ||
|
||
SEARCH_PATTERN=$(echo "$VERSION_STR" | awk -F '.' 'BEGIN { OFS="" } {print "^holochain-", $1, ".", $2, ".[0-9]+-rc.[0-9]+$"}') | ||
;; | ||
main-*) | ||
VERSION_STR=$(echo "$CURRENT_BRANCH" | awk -F '-' '{print $2}') | ||
|
||
# Protect against this code trying to bump 1.2.3 versions if one of those shows up. | ||
SEP_COUNT=$(echo "$VERSION_STR" | tr -d -c '.' | awk '{ print length; }') | ||
if [ "$SEP_COUNT" -ne "1" ]; then | ||
echo "Invalid version format: $VERSION_STR" | ||
exit 1 | ||
fi | ||
|
||
SEARCH_PATTERN=$(echo "$VERSION_STR" | awk -F '.' 'BEGIN { OFS="" } {print "^holochain-", $1, ".", $2, ".[0-9]+$"}') | ||
;; | ||
*) | ||
echo "Not on branch main or main-X.Y, skipping for branch [${CURRENT_BRANCH}]" | ||
exit 0 | ||
;; | ||
esac | ||
|
||
echo "Looking for tags matching pattern: $SEARCH_PATTERN" | ||
|
||
ALL_HOLOCHAIN_TAGS=$(git -c 'versionsort.suffix=-beta-dev' -c 'versionsort.suffix=-dev' -c 'versionsort.suffix=-rc' ls-remote -q --tags --sort='v:refname' https://github.com/holochain/holochain.git | cut --delimiter='/' --fields=3) | ||
LATEST_MATCHING_TAG=$(echo "$ALL_HOLOCHAIN_TAGS" | grep -E "$SEARCH_PATTERN" | tail -n 1) | ||
|
||
if [ -z "$LATEST_MATCHING_TAG" ]; then | ||
echo "No matching tag found for: $VERSION_STR" | ||
exit 1 | ||
fi | ||
|
||
echo "Latest matching tag: $LATEST_MATCHING_TAG" | ||
|
||
APPLY=${2:-true} | ||
if [ "$APPLY" == "true" ]; then | ||
sed --in-place "s#url = \"github:holochain/holochain/.*\";#url = \"github:holochain/holochain/${LATEST_MATCHING_TAG}\";#" ./flake.nix | ||
nix flake update holochain | ||
else | ||
printf "Would have updated flake.nix to use: \n%s\n" "$LATEST_MATCHING_TAG" | ||
fi |
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,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eu | ||
|
||
if ! ( | ||
(git config --global user.email && git config --global user.name) || | ||
(git config --local user.email && git config --local user.name) | ||
); then | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "Holochain Release Automation" | ||
fi |