Skip to content

system build

system build #165

Workflow file for this run

name: 'system build'
on:
repository_dispatch:
types: [Build-check]
push:
branches:
- master
paths:
- 'hosts/tests/**/*.nix'
- 'parts/**/*.nix'
- 'flake.lock'
pull_request_target:
branches:
- master
paths:
- 'parts/**/*.nix'
- 'modules/**.nix'
- 'hosts/**/*.nix'
- 'flake.lock'
# schedule:
# # run this daily at 8am UTC, or roughly 4am eastern
# - cron: '45 2 * * 6'
workflow_dispatch:
jobs:
use_branch:
runs-on: ubuntu-latest
outputs:
MY_TARGET_BRANCH: ${{ steps.determine_branch.outputs.runbranch }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
- name: get last commit time of master branch
id: get_master_time
run: |
git fetch origin master
MASTER_COMMIT_TIME=$(git log -1 --format=%ct origin/master)
echo "Current flakebot Last commit time is ${MASTER_COMMIT_TIME}"
echo "MASTER_COMMIT_TIME=${MASTER_COMMIT_TIME}" >> $GITHUB_ENV
- name: get last commit time of flakebot
id: get_flakebot_time
run: |
git fetch origin flakebot
FLAKEBOT_COMMIT_TIME=$(git log -1 --format=%ct origin/flakebot)
echo "Current flakebot Last commit time is ${FLAKEBOT_COMMIT_TIME}"
echo "FLAKEBOT_COMMIT_TIME=${FLAKEBOT_COMMIT_TIME}" >> $GITHUB_ENV
- name: use target branch
id: determine_branch
run: |
if [[ "${MASTER_COMMIT_TIME}" -gt "${FLAKEBOT_COMMIT_TIME}" ]]; then
echo "Will be working on master branch"
echo "runbranch=master" >> $GITHUB_OUTPUT
else
echo "Will be working on flakebot branch"
echo "runbranch=flakebot" >> $GITHUB_OUTPUT
fi
build:
needs:
- use_branch
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
runs-on: ${{ matrix.os }}
env:
MY_TARGET_BRANCH: ${{ needs.use_branch.outputs.MY_TARGET_BRANCH }}
steps:
- uses: actions/checkout@v4
with:
# Shallow clones won't work
fetch-depth: 0
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
if: ${{ matrix.os == 'ubuntu-latest' }}
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: Free Disk Space (macos)
if: ${{ matrix.os == 'macos-latest' }}
run: |
df -h
brew list
[[ -d /Applications/Xcode_16.1_beta.app ]] && sudo rm -rf /Applications/Xcode_16.1_beta.app
[[ -d /Applications/Xcode_16_beta_6.app ]] && sudo rm -rf /Applications/Xcode_16_beta_6.app
[[ -d /Applications/Xcode_15.1.app ]] && sudo rm -rf /Applications/Xcode_15.1.app
[[ -d /Applications/Xcode_15.2.app ]] && sudo rm -rf /Applications/Xcode_15.2.app
[[ -d /Applications/Xcode_15.3.app ]] && sudo rm -rf /Applications/Xcode_15.3.app
[[ -d /Applications/Xcode_14.3.1.app ]] && sudo rm -rf /Applications/Xcode_14.3.1.app
[[ -d /Applications/Xcode_15.0.1.app ]] && sudo rm -rf /Applications/Xcode_15.0.1.app
brew uninstall --zap google-chrome
df -h
- name: checkout target branch
run: |
git fetch
git checkout ${MY_TARGET_BRANCH}
echo "Working on ${MY_TARGET_BRANCH} branch"
- uses: cachix/install-nix-action@v30
with:
extra_nix_config: |
experimental-features = nix-command flakes
# access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- uses: cachix/cachix-action@v15
with:
name: shanyouli
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Print CPU info
run: |
if command -v nproc >/dev/null ; then
echo "Cores: $(nproc), Arch: $(uname -p)"
else
echo "Cores: $(nix shell nixpkgs#coreutils-full -c nproc) , Arch: $(uname -p)"
fi
- name: Run Flake Checks
run: |
nix flake check --show-trace --impure
timeout-minutes: 240
merge-to-master:
needs:
- use_branch
- build
if: needs.use_branch.outputs.MY_TARGET_BRANCH == 'flakebot'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
- name: Prepare flakebot branch
run: |
git config --local user.email "[email protected]"
git config --local user.name "flakebot"
git fetch
git checkout flakebot
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: master
force: true