|
| 1 | +name: Build test and deploy ZFS packages for Debian 10, Ubuntu 18.04 and later |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - master |
| 6 | + paths-ignore: |
| 7 | + - 'README.md' |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + name: Building packages |
| 11 | + runs-on: ubuntu-18.04 |
| 12 | + steps: |
| 13 | + - name: clone zfs upstream repo |
| 14 | + shell: bash |
| 15 | + run: | |
| 16 | + mkdir ~/zfs && cd ~/zfs |
| 17 | + git init |
| 18 | + git fetch https://github.com/openzfs/zfs.git refs/heads/master |
| 19 | + git checkout FETCH_HEAD |
| 20 | + - name: clone our zfs ubuntu repo |
| 21 | + shell: bash |
| 22 | + run: | |
| 23 | + echo "ref triggered = ${{ github.ref }}" |
| 24 | + mkdir ~/zfs/debian && cd ~/zfs/debian |
| 25 | + git init |
| 26 | + git fetch https://github.com/${{ github.repository }}.git ${{ github.ref }} --depth=1 |
| 27 | + git checkout FETCH_HEAD |
| 28 | + - name: retrieve build packages |
| 29 | + shell: bash |
| 30 | + run: | |
| 31 | + sudo DEBIAN_FRONTEND=noninteractive apt-get -yq update |
| 32 | + sudo DEBIAN_FRONTEND=noninteractive apt-get -yq install dpkg-dev alien autoconf automake build-essential dkms fakeroot gawk gdebi-core libacl1-dev libaio-dev libattr1-dev libblkid-dev libdevmapper-dev libelf-dev libselinux-dev libssl-dev libtool libudev-dev nfs-kernel-server python3 python3-dev python3-cffi python3-setuptools uuid-dev zlib1g-dev linux-headers-$(uname -r) python3-all-dev python3-sphinx |
| 33 | + - name: build zfs packages |
| 34 | + shell: bash |
| 35 | + run: | |
| 36 | + echo "current folder" |
| 37 | + pwd |
| 38 | + cd ~/zfs |
| 39 | + ls ./debian/changelog |
| 40 | + dpkg-buildpackage -b -rfakeroot -us -uc --no-sign |
| 41 | + mkdir ./zfs-deb-packages |
| 42 | + cp ../*.deb ./zfs-deb-packages |
| 43 | + ls ./zfs-deb-packages -al |
| 44 | + - name: cache created packages |
| 45 | + uses: actions/cache@v1 |
| 46 | + with: |
| 47 | + path: ~/zfs/zfs-deb-packages |
| 48 | + key: ${{ runner.OS }}-zfs-${{ github.sha }} |
| 49 | + test: |
| 50 | + needs: build |
| 51 | + name: Testing packages |
| 52 | + runs-on: ubuntu-18.04 |
| 53 | + strategy: |
| 54 | + fail-fast: true |
| 55 | + matrix: |
| 56 | + testbatch: |
| 57 | + - 'alloc_class,limits,arc,channel_program,cp_files,deadman,btree,cache,history,hkdf,inuse,zfs_property,zfs_receive,zfs_reservation,zfs_send,zfs_set,zfs_share,zfs_snapshot,zfs_unload-key,zfs_unmount,zfs_unshare,zfs_upgrade,zpool,zpool_destroy,zpool_detach' |
| 58 | + - 'rootpool,scrub_mirror,pool_checkpoint' |
| 59 | + - 'acl,atime,bootfs,cachefile,casenorm,chattr,checksum,clean_mirror,compression,ctime,delegate,devices,events,exec,fault,features,grow_pool' |
| 60 | + - 'grow_replicas,mv_files,cli_user,zfs_mount,zfs_promote,zfs_rollback,zpool_events,zpool_expand,zpool_export,zpool_add,zpool_attach,zpool_clear,zpool_create' |
| 61 | + - 'zpool_get,zpool_history,zpool_import,zpool_labelclear,zpool_offline,zpool_online' |
| 62 | + - 'zpool_reopen,zpool_remove,zpool_replace,zpool_scrub,zpool_set,zpool_status,zpool_sync,zpool_upgrade,redacted_send,redundancy' |
| 63 | + - 'zfs_destroy,large_files,largest_pool,link_count,migration,inheritance,refquota,refreserv,rename_dirs,replacement,log_spacemap,persist_l2arc,reservation' |
| 64 | + - 'zfs,zfs_bookmark,zfs_change-key,zfs_clone,zfs_copies,zfs_create,zfs_diff,zfs_get,zfs_inherit,zfs_load-key,zfs_rename,mmap,mmp,mount,nestedfs,no_space,nopwrite,online_offline,pool_names,poolversion' |
| 65 | + - 'zdb,mmp' |
| 66 | + - 'privilege,quota,raidz,redundancy,rsend' |
| 67 | + - 'slog,snapshot,snapused,sparse,threadsappend,tmpfile,truncate,upgrade,userquota,vdev_zaps,write_dirs,xattr,zvol,libzfs' |
| 68 | + steps: |
| 69 | + - name: Restore cached packages |
| 70 | + uses: actions/cache@v1 |
| 71 | + with: |
| 72 | + path: ./zfs-deb-packages |
| 73 | + key: ${{ runner.OS }}-zfs-${{ github.sha }} |
| 74 | + - name: setup local repo and put earlier-built ZFS packages there |
| 75 | + shell: bash |
| 76 | + run: | |
| 77 | + cd ./zfs-deb-packages |
| 78 | + ls ./ -alt |
| 79 | + pwd |
| 80 | + sudo bash -c "dpkg-scanpackages -m . > Packages" |
| 81 | + sudo bash -c "echo 'deb [trusted=yes] file:$(pwd) ./' >> /etc/apt/sources.list" |
| 82 | + sudo bash -c "echo -e \"Package: *\nPin: origin \\\"\\\"\nPin-Priority: 1001\" > /etc/apt/preferences.d/90_zfs" |
| 83 | + sudo DEBIAN_FRONTEND=noninteractive apt-get -yq update |
| 84 | + - name: install earlier-built ZFS packages along with packages required for conducting tests |
| 85 | + shell: bash |
| 86 | + run: | |
| 87 | + sudo DEBIAN_FRONTEND=noninteractive apt-get -yq install linux-modules-extra-$(uname -r) |
| 88 | + sudo bash -c "echo \"zfs-dkms zfs-dkms/note-incompatible-licenses note true\" | debconf-set-selections" |
| 89 | + sudo DEBIAN_FRONTEND=noninteractive apt-get -yq install zfs-dkms zfsutils-linux zfs-zed zfs-test parted lsscsi ksh attr acl fio quota nfs-kernel-server samba-common-bin linux-tools-generic linux-tools-$(uname -r) linux-cloud-tools-$(uname -r) |
| 90 | + zfs version |
| 91 | + - name: run tests |
| 92 | + shell: bash |
| 93 | + run: | |
| 94 | + sudo rm -rf /etc/hostid |
| 95 | + /usr/share/zfs/zfs-tests.sh -v -T ${{ matrix.testbatch }} |
| 96 | + - name: show test output on failure |
| 97 | + if: failure() |
| 98 | + shell: bash |
| 99 | + run: | |
| 100 | + find /var/tmp/test_results/current/log -type f -name '*' -printf "%f\n" -exec cut -c -800 {} \; |
| 101 | + deploy: |
| 102 | + needs: test |
| 103 | + name: Deploying artefacts to debian repository |
| 104 | + runs-on: ubuntu-18.04 |
| 105 | + steps: |
| 106 | + - name: Restore cached packages |
| 107 | + uses: actions/cache@v1 |
| 108 | + with: |
| 109 | + path: ./zfs-deb-packages |
| 110 | + key: ${{ runner.OS }}-zfs-${{ github.sha }} |
| 111 | + - name: adding required packages for repo publishing |
| 112 | + shell: bash |
| 113 | + run: | |
| 114 | + sudo bash -c "echo 'deb http://repo.aptly.info/ squeeze main' >> /etc/apt/sources.list" |
| 115 | + wget -qO - https://www.aptly.info/pubkey.txt | sudo apt-key add - |
| 116 | + sudo DEBIAN_FRONTEND=noninteractive apt-get -yq update |
| 117 | + sudo DEBIAN_FRONTEND=noninteractive apt-get -yq install gnupg aptly |
| 118 | + - name: create repo and add packages |
| 119 | + shell: bash |
| 120 | + run: | |
| 121 | + aptly repo create -distribution="zfs-debian-experimental" -component="main" zfs-debian-experimental |
| 122 | + sed -i 's/\"architectures\": \[\]/\"architectures\": \[\"amd64\"\]/g' ~/.aptly.conf |
| 123 | + echo -n "${{ secrets.GPG_KEY }}" > ./apt-private-key.asc |
| 124 | + echo ${{ secrets.GPG_PASS }} | gpg --batch --import ./apt-private-key.asc |
| 125 | + rm -rf ./apt-private-key.asc |
| 126 | + ls ./zfs-deb-packages/*.deb -1 | xargs aptly repo add zfs-debian-experimental |
| 127 | + aptly publish repo --gpg-key="$(gpg --list-public-keys --keyid-format 0xLONG | sed -n -E 's/^pub\s+\w{1,30}[0-9]+\/0x([0-9A-Z]+)\s+.+$/\1/p')" --batch=true --passphrase="${{ secrets.GPG_PASS }}" zfs-debian-experimental |
| 128 | + rm -rf ./zfs-deb-packages |
| 129 | + - uses: actions/checkout@v2 |
| 130 | + with: |
| 131 | + ref: gh-pages |
| 132 | + - name: push updates |
| 133 | + shell: bash |
| 134 | + run: |2 |
| 135 | + git config --global user.email "$(git log -n 1 --format=format:%ae)" |
| 136 | + git config --global user.name "$(git log -n 1 --format=format:%an)" |
| 137 | + rm ./public -rf |
| 138 | + cp -r /home/runner/.aptly/public ./ |
| 139 | + export PAGE_FOOTER_DATE_TAG=$(date -Is) |
| 140 | + sed -i -E "s/(<span class=\"datetag\">)[^<]*(<\/span>)/\1${PAGE_FOOTER_DATE_TAG}\2/" ./index.html |
| 141 | + python - <<END |
| 142 | + import os |
| 143 | + indexTextStart = """<!DOCTYPE html> |
| 144 | + <html> |
| 145 | + <head><title>Index of {folderPath}</title></head> |
| 146 | + <body> |
| 147 | + <h2>Index of {folderPath}</h2> |
| 148 | + <hr> |
| 149 | + <ul> |
| 150 | + <li> |
| 151 | + <a href='../'>../</a> |
| 152 | + </li> |
| 153 | + """ |
| 154 | + indexTextEnd = """ |
| 155 | + </ul> |
| 156 | + <hr/> |
| 157 | + <p>Page generated: ${PAGE_FOOTER_DATE_TAG}</p> |
| 158 | + </body> |
| 159 | + </html> |
| 160 | + """ |
| 161 | + def index_folder(folderPath): |
| 162 | + print("Indexing: " + folderPath +'/') |
| 163 | + files = os.listdir(folderPath) |
| 164 | + root = folderPath |
| 165 | + if folderPath == '.': |
| 166 | + root = 'Root' |
| 167 | + indexText = indexTextStart.format(folderPath=root) |
| 168 | + for file in files: |
| 169 | + if file != 'index.html': |
| 170 | + indexText += "\t\t<li>\n\t\t\t<a href='" + file + "'>" + file + "</a>\n\t\t</li>\n" |
| 171 | + if os.path.isdir(folderPath+'/'+file): |
| 172 | + index_folder(folderPath + '/' + file) |
| 173 | + indexText += indexTextEnd |
| 174 | + index = open(folderPath+'/index.html', "w") |
| 175 | + index.write(indexText) |
| 176 | + index_folder('./public') |
| 177 | + END |
| 178 | + rm -rf ./.git |
| 179 | + git init |
| 180 | + git checkout --orphan "gh-pages" |
| 181 | + git remote add origin "https://x-access-token:${{ secrets.GITHUB_PERSONAL_TOKEN }}@github.com/${{ github.repository }}.git" |
| 182 | + git add --all |
| 183 | + git commit -am "automatic pages update from ${{ github.ref }} commit ${{ github.sha }}" |
| 184 | + git push --force --set-upstream origin gh-pages |
0 commit comments