|
| 1 | +on: |
| 2 | + push: |
| 3 | + pull_request: |
| 4 | +name: build |
| 5 | +jobs: |
| 6 | + build: |
| 7 | + name: build |
| 8 | + runs-on: ubuntu-22.04 |
| 9 | + steps: |
| 10 | + - uses: actions/checkout@v3 |
| 11 | + - name: Set up golang |
| 12 | + uses: actions/setup-go@v2 |
| 13 | + with: |
| 14 | + go-version: 1.21 |
| 15 | + - name: install dependencies |
| 16 | + run: | |
| 17 | + sudo apt-get update |
| 18 | + sudo apt-get install bats fuse3 make \ |
| 19 | + libcryptsetup-dev libgpgme-dev libcap-dev lxc \ |
| 20 | + libdevmapper-dev libacl1-dev libarchive-tools squashfs-tools |
| 21 | + - name: setup lxc |
| 22 | + run: | |
| 23 | + chmod ugo+x $HOME |
| 24 | + cat /etc/subuid /etc/subgid |
| 25 | + u=$(id -un) && g=$(id -gn) |
| 26 | + echo "u=$u g=$g" |
| 27 | + uidmap=$(awk -F: '$1 == u { print $2, $3 }' "u=$u" /etc/subuid) |
| 28 | + gidmap=$(awk -F: '$1 == g { print $2, $3 }' "g=$g" /etc/subgid) |
| 29 | + if [ "$u" = "runner" ] && [ -z "$gidmap" ]; then |
| 30 | + # 'id -gn' shows docker, but 'runner' is in subgid |
| 31 | + g="runner" |
| 32 | + gidmap=$(awk -F: '$1 == g { print $2, $3 }' "g=$g" /etc/subgid) |
| 33 | + fi |
| 34 | + echo "uidmap=$uidmap." |
| 35 | + echo "gidmap=$gidmap." |
| 36 | + [ -n "$uidmap" ] && [ -n "$gidmap" ] || |
| 37 | + { echo "did not get uidmap or gidmap for u=$u g=$g"; exit 1; } |
| 38 | + mkdir -p ~/.config/lxc/ |
| 39 | + echo "writing .config/lxc/default.conf" |
| 40 | + tee ~/.config/lxc/default.conf <<EOF |
| 41 | + lxc.include = /etc/lxc/default.conf |
| 42 | + lxc.idmap = u 0 $uidmap |
| 43 | + lxc.idmap = g 0 $gidmap |
| 44 | + EOF |
| 45 | + set -x |
| 46 | + cat ~/.config/lxc/default.conf |
| 47 | + cat /etc/subuid |
| 48 | + |
| 49 | + echo "writing /etc/lxc/lxc-usernet" |
| 50 | + echo "$u veth lxcbr0 100" | sudo tee -a /etc/lxc/lxc-usernet |
| 51 | + - name: install skopeo |
| 52 | + run: | |
| 53 | + wget -O ~/bin/skopeo --progress=dot:mega https://github.com/project-machine/tools/releases/download/v0.0.1/skopeo |
| 54 | + chmod 755 ~/bin/skopeo |
| 55 | + sudo cp -f ~/bin/skopeo /usr/bin/skopeo |
| 56 | + - name: lint |
| 57 | + run: | |
| 58 | + make gofmt |
| 59 | + - name: make |
| 60 | + run: | |
| 61 | + go get -v ./... |
| 62 | + make |
| 63 | + mkdir -p ~/bin |
| 64 | + cp atomfs ~/bin |
| 65 | + - name: test |
| 66 | + run: | |
| 67 | + export PATH=~/bin:$PATH |
| 68 | + skopeo copy docker://zothub.io/machine/bootkit/bootkit:v0.0.16.230901-squashfs oci:oci:bootkit-squashfs |
| 69 | + mkdir upper |
| 70 | + atomfs mount --upper=upper oci:bootkit-squashfs dest |
| 71 | + [ -d dest/bootkit ] |
| 72 | + touch dest/zz |
| 73 | + atomfs umount dest |
| 74 | + [ -f upper/zz ] |
| 75 | + |
| 76 | + - name: Release |
| 77 | + uses: softprops/action-gh-release@v1 |
| 78 | + if: startsWith(github.ref, 'refs/tags/') |
| 79 | + with: |
| 80 | + files: | |
| 81 | + atomfs |
0 commit comments