Skip to content

Commit

Permalink
add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
declantsien committed May 15, 2024
1 parent 634dced commit 1617f54
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 459 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: build
on:
push:
paths-ignore:
- 'README.org'
- '.guix-authorizations'
- '.guix-channel'
pull_request:
schedule:
# weekly builds, making sure everything still works with guix-proper
- cron: '39 3 * * 0'
jobs:
build:
name: Build package
runs-on: ubuntu-latest
strategy:
# building independent packages, don’t abort entire build if one fails
fail-fast: false
matrix:
package:
- rust-bin
steps:
- name: Guix cache
uses: actions/cache@v2
with:
path: ~/.cache/guix
# use a key that (almost) never matches
key: guix-cache-${{ github.sha }}
restore-keys: |
guix-cache-
- name: Install Guix
uses: PromyLOPh/guix-install-action@v1
- name: Checkout
uses: actions/checkout@v2
- name: Lint package
run: |
GUIX_PROFILE="/home/runner/.config/guix/current"
. "$GUIX_PROFILE/etc/profile"
guix lint -L . ${{ matrix.package }} |& sed -nre 's#(.*):([0-9]+):([0-9]+): (.*)$#::warning file=\1,line=\2,col=\3::\4#gp'
- name: Build package
run: |
GUIX_PROFILE="/home/runner/.config/guix/current"
. "$GUIX_PROFILE/etc/profile"
guix build -L . ${{ matrix.package }}
49 changes: 49 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: test
on: [push]
jobs:
build-with-channels:
name: Test as Guix channel
runs-on: ubuntu-latest
strategy:
# building independent packages, don’t abort entire build if one fails
fail-fast: false
steps:
- name: Guix cache
uses: actions/cache@v3
with:
path: ~/.cache/guix
# use a key that (almost) never matches
key: guix-cache-${{ github.sha }}
restore-keys: |
guix-cache-
# Cannot use a cache for /gnu/store, since restore fails
- name: Install Guix
id: install-guix
uses: PromyLOPh/guix-install-action@v1
with:
channels: |-
(list (channel
(name 'guix)
(url "https://github.com/declantsien/guix")
(branch "master")
(commit
"da9f509b0300f1b6b979c68a52d8669f9bcb89a7")
(introduction
(make-channel-introduction
"9edb3f66fd807b096b48283debdcddccfea34bad"
(openpgp-fingerprint
"BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA"))))
(channel
(name 'rustup)
(url "https://github.com/declantsien/guix-rustup")
(introduction
(make-channel-introduction
"325d3e2859d482c16da21eb07f2c6ff9c6c72a80"
(openpgp-fingerprint
"F695 F39E C625 E081 33B5 759F 0FC6 8703 75EF E2F5")))))
- name: Build
run: guix build rust-bin
- name: Build
run: guix build -e '((@@ (rustup build toolchain) rustup) "1.78.0")'
- name: Build
run: guix build -e '((@@ (rustup build toolchain) rustup) "nightly-2024-05-13")'
24 changes: 9 additions & 15 deletions rustup/build/manifest.scm
Original file line number Diff line number Diff line change
Expand Up @@ -493,24 +493,18 @@
(define channel-hash-file-hash
(let* ((content (http-fetch/guarded sha256-url)))
(if content
(base32-from-sha256 (car (string-split
content
#\ )))
(car (string-split
content
#\ ))
(begin
(format #t "Failed to download manifest sha256 ~a ~a~%" sha256-url str)
#f))))
(if channel-hash-file-hash
(let* ((%store (open-connection))
(drv (url-fetch* %store url 'sha256 (nix-base32-string->bytevector channel-hash-file-hash)))
(out-path (derivation->output-path drv)))
(and (build-derivations %store (list drv))
(file-exists? out-path)
(valid-path? %store out-path)
(call-with-input-file out-path
(lambda (port)
(let* ((content (get-string-all port)))
(parse-toml content))))))
#f))
(let* ((content (http-fetch/guarded url channel-hash-file-hash)))
(if content
(parse-toml content)
(begin
(format #t "Failed to download manifest toml ~a ~a~%" url str)
#f))))

(define* (compact-manifest str #:optional manifest)
(define c (channel->from-str str))
Expand Down
11 changes: 8 additions & 3 deletions rustup/build/utils.scm
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
#:use-module (guix http-client)
#:use-module (guix base16)
#:use-module (guix base32)
#:use-module (gcrypt hash)
#:use-module (web uri)
#:use-module (ice-9 textual-ports)
#:use-module (ice-9 match)
#:use-module (ice-9 match)
#:use-module (rnrs bytevectors)
#:export (http-fetch/guarded
channel-str-normalize
base32-from-sha256))

(define* (http-fetch/guarded url)
(define* (http-fetch/guarded url #:optional (hash #f))
;; Handle 404
(guard (c ((http-get-error? c)
(if (= 404 (http-get-error-code c)) ;"Not Modified"
Expand All @@ -19,8 +21,11 @@
(#t c))
(let* ((port (http-fetch/cached (string->uri url)
#:ttl (* 6 3600)))
(content (get-string-all port)))
(content (get-string-all port))
(checksum (if hash (bytevector->base16-string (sha256 (string->utf8 content))) #f)))
(close-port port)
(when (and hash (not (string= hash checksum)))
(error (format #t "~%!Error: sha256 mismatch~%Expecting: ~a~%Actual: ~a~%~%" hash checksum)))
content)))

(define* (base32-from-sha256 sha256)
Expand Down
Loading

0 comments on commit 1617f54

Please sign in to comment.