Skip to content

Commit

Permalink
add github action
Browse files Browse the repository at this point in the history
  • Loading branch information
manveru committed Sep 26, 2023
1 parent 92544ce commit bb05788
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 24 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Update
run-name: ${{github.actor}} is updating capkgs
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
permissions:
contents: read
pull-requests: read
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v23
with:
extra_nix_config: |
trusted-public-keys = hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ= cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=
substituters = https://cache.iog.io https://cache.nixos.org/
- run: echo "${{secrets.NIX_SIGNING_KEY}}" > hydra_key
- run: nix develop --ignore-environment --keep AWS_ACCESS_KEY_ID --keep AWS_SECRET_ACCESS_KEY --command just packages
env:
AWS_ACCESS_KEY_ID: "${{secrets.AWS_ACCESS_KEY_ID}}"
AWS_SECRET_ACCESS_KEY: "${{secrets.AWS_SECRET_ACCESS_KEY}}"
- run: nix develop --ignore-environment --command just check
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/evals
/closures
/builds
1 change: 1 addition & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ packages *ARGS:
./packages.rb \
--from "s3://devx?profile=r2&secret-key=hydra_key&endpoint=fc0e8a9d61fc1f44f378bdc5fdc0f638.r2.cloudflarestorage.com&region=auto&compression=zstd" \
--to "s3://devx?profile=r2&secret-key=hydra_key&endpoint=fc0e8a9d61fc1f44f378bdc5fdc0f638.r2.cloudflarestorage.com&region=auto&compression=zstd" \
--gc \
--systems x86_64-linux {{ARGS}}

# Attempt to build all packages from this flake
Expand Down
3 changes: 2 additions & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

# These inputs are purely used for the devShell and hydra to avoid any
# evaluation and download of nixpkgs for just building a package.
inherit (flakes.nixpkgs.legacyPackages.${system}) mkShell nushell just ruby solargraph treefmt curl;
inherit (flakes.nixpkgs.legacyPackages.${system}) mkShell nushell just ruby solargraph treefmt curl gitMinimal;

# At least 2.17 is required for this fix: https://github.com/NixOS/nix/pull/4282
inherit (flakes.nix.packages.${system}) nix;
Expand All @@ -49,6 +49,7 @@
nix
treefmt
curl
gitMinimal
];
};
}
Expand Down
29 changes: 6 additions & 23 deletions packages.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require 'optparse'
require 'fileutils'

OPTIONS = {systems: "x86-64_linux"}
OPTIONS = {systems: "x86-64_linux", gc: false}

op = OptionParser.new do |parser|
parser.banner = "Usage: capkgs [options]"
Expand All @@ -27,6 +27,10 @@
OPTIONS[:systems] = v
end

parser.on '--gc', "garbage collect after every package" do |v|
OPTIONS[:gc] = true
end

parser.on '-h', '--help' do
puts parser
exit
Expand Down Expand Up @@ -59,28 +63,6 @@ def to_json(options)
end
end

def process(pkg, flake_url, org, repo, tag, rev)
pkg.merge!('org' => org, 'repo' => repo, 'tag' => tag, 'rev' => rev)

return if pkg['fail']

puts "Processing #{flake_url}"

(merge(pkg) { process_eval(flake_url) }) &&
(set(pkg, 'closure') { process_closure(flake_url) })

puts "Marked #{flake_url} as failed" if pkg['fail']
end

def nix_make_content_addressed(out_path)
content_addressed, status =
sh 'nix', 'store', 'make-content-addressed', out_path.fetch('outputs').fetch('out'),
'--json',
'--from', OPTIONS.fetch(:from),
'--to', OPTIONS.fetch(:to)
content_addressed if status.success?
end

def fetch_git_branches(org_name, repo_name, branches, dest)
url = "https://github.com/#{org_name}/#{repo_name}"

Expand Down Expand Up @@ -280,6 +262,7 @@ def process(path, cmd)
pkg.nix_eval &&
pkg.nix_build &&
pkg.nix_store_make_content_addressed
sh('nix-collect-garbage') if OPTIONS[:gc]
valid[pkg.flake_url] = pkg.to_h if pkg.closure.any?
end

Expand Down

0 comments on commit bb05788

Please sign in to comment.