fork/numbat
git clone https://git.julia.blue/fork/numbat
9800cc2
v1.6.2
1name : CICD 2 3env : 4CICD_INTERMEDIATES_DIR : "_cicd-intermediates" 5MSRV_FEATURES : "" 6 7on : 8workflow_dispatch : 9pull_request : 10push : 11branches : 12- master 13tags : 14- '*' 15 16jobs : 17crate_metadata : 18name : Extract crate metadata 19runs-on : ubuntu-latest 20steps : 21- uses : actions/checkout@v3 22- name : Extract crate information 23id : crate_metadata 24run : | 25cargo metadata --no-deps --format-version 1 | jq -r '"name=" + .packages[0].name' | tee -a $GITHUB_OUTPUT 26cargo metadata --no-deps --format-version 1 | jq -r '"version=" + .packages[0].version' | tee -a $GITHUB_OUTPUT 27cargo metadata --no-deps --format-version 1 | jq -r '"maintainer=" + .packages[0].authors[0]' | tee -a $GITHUB_OUTPUT 28cargo metadata --no-deps --format-version 1 | jq -r '"homepage=" + .packages[0].homepage' | tee -a $GITHUB_OUTPUT 29cargo metadata --no-deps --format-version 1 | jq -r '"msrv=" + .packages[0].rust_version' | tee -a $GITHUB_OUTPUT 30outputs : 31name : ${{ steps.crate_metadata.outputs.name }} 32version : ${{ steps.crate_metadata.outputs.version }} 33maintainer : ${{ steps.crate_metadata.outputs.maintainer }} 34homepage : ${{ steps.crate_metadata.outputs.homepage }} 35msrv : ${{ steps.crate_metadata.outputs.msrv }} 36 37ensure_cargo_fmt : 38name : Ensure 'cargo fmt' has been run 39runs-on : ubuntu-20.04 40steps : 41- uses : dtolnay/rust-toolchain@stable 42with : 43components : rustfmt 44- uses : actions/checkout@v3 45- run : cargo fmt -- --check 46 47documentation_checks : 48name : Documentation checks 49runs-on : ubuntu-20.04 50steps : 51- uses : dtolnay/rust-toolchain@stable 52- uses : actions/checkout@v3 53- name : Install mdbook 54run : | 55cargo install mdbook 56cargo install mdbook-linkcheck 57- name : Build documentation 58run : | 59cd book 60bash build.sh 61if [ -n "$(git status --porcelain)" ]; then 62echo "Documentation not up to date." 63echo "Make sure to run 'build.sh' in the documentation/ folder" 64exit 1 65fi 66 67min_version : 68name : Minimum supported rust version 69runs-on : ubuntu-20.04 70needs : crate_metadata 71steps : 72- name : Checkout source code 73uses : actions/checkout@v3 74 75- name : Install rust toolchain (v${{ needs.crate_metadata.outputs.msrv }}) 76uses : dtolnay/rust-toolchain@master 77with : 78toolchain : ${{ needs.crate_metadata.outputs.msrv }} 79components : clippy 80- name : Run clippy (on minimum supported rust version to prevent warnings we can't fix) 81run : cargo clippy --locked --all-targets ${{ env.MSRV_FEATURES }} 82- name : Run tests 83run : cargo test --locked ${{ env.MSRV_FEATURES }} 84 85build : 86name : ${{ matrix.job.target }} (${{ matrix.job.os }}) 87runs-on : ${{ matrix.job.os }} 88needs : crate_metadata 89strategy : 90fail-fast : false 91matrix : 92job : 93- { target : aarch64-unknown-linux-gnu , os : ubuntu-20.04 , use-cross : true } 94- { target : arm-unknown-linux-gnueabihf , os : ubuntu-20.04 , use-cross : true } 95- { target : arm-unknown-linux-musleabihf , os : ubuntu-20.04 , use-cross : true } 96- { target : i686-pc-windows-msvc , os : windows-2019 } 97- { target : i686-unknown-linux-gnu , os : ubuntu-20.04 , use-cross : true } 98- { target : i686-unknown-linux-musl , os : ubuntu-20.04 , use-cross : true } 99- { target : x86_64-apple-darwin , os : macos-12 } 100#- { target: x86_64-pc-windows-gnu , os: windows-2019 } 101- { target : x86_64-pc-windows-msvc , os : windows-2019 } 102- { target : x86_64-unknown-linux-gnu , os : ubuntu-20.04 , use-cross : true } 103- { target : x86_64-unknown-linux-musl , os : ubuntu-20.04 , use-cross : true } 104env : 105BUILD_CMD : cargo 106steps : 107- name : Checkout source code 108uses : actions/checkout@v3 109 110- name : Install prerequisites 111shell : bash 112run : | 113case ${{ matrix.job.target }} in 114arm-unknown-linux-*) sudo apt-get -y update ; sudo apt-get -y install gcc-arm-linux-gnueabihf ;; 115aarch64-unknown-linux-gnu) sudo apt-get -y update ; sudo apt-get -y install gcc-aarch64-linux-gnu ;; 116esac 117 118- name : Install Rust toolchain 119uses : dtolnay/rust-toolchain@stable 120with : 121targets : ${{ matrix.job.target }} 122 123- name : Install cross 124if : matrix.job.use-cross 125uses : taiki-e/install-action@v2 126with : 127tool : cross 128 129- name : Overwrite build command env variable 130if : matrix.job.use-cross 131shell : bash 132run : echo "BUILD_CMD=cross" >> $GITHUB_ENV 133 134- name : Show version information (Rust, cargo, GCC) 135shell : bash 136run : | 137gcc --version || true 138rustup -V 139rustup toolchain list 140rustup default 141cargo -V 142rustc -V 143 144- name : Build 145shell : bash 146run : $BUILD_CMD build --locked --release --target=${{ matrix.job.target }} 147 148- name : Set binary name & path 149id : bin 150shell : bash 151run : | 152# Figure out suffix of binary 153EXE_suffix="" 154case ${{ matrix.job.target }} in 155*-pc-windows-*) EXE_suffix=".exe" ;; 156esac; 157 158# Setup paths 159BIN_NAME="${{ needs.crate_metadata.outputs.name }}${EXE_suffix}" 160BIN_PATH="target/${{ matrix.job.target }}/release/${BIN_NAME}" 161 162# Let subsequent steps know where to find the binary 163echo "BIN_PATH=${BIN_PATH}" >> $GITHUB_OUTPUT 164echo "BIN_NAME=${BIN_NAME}" >> $GITHUB_OUTPUT 165 166- name : Set testing options 167id : test-options 168shell : bash 169run : | 170# test only library unit tests and binary for arm-type targets 171unset CARGO_TEST_OPTIONS 172unset CARGO_TEST_OPTIONS ; case ${{ matrix.job.target }} in arm-* | aarch64-*) CARGO_TEST_OPTIONS="--lib --bin ${{ needs.crate_metadata.outputs.name }}" ;; esac; 173echo "CARGO_TEST_OPTIONS=${CARGO_TEST_OPTIONS}" >> $GITHUB_OUTPUT 174 175- name : Run tests 176shell : bash 177run : $BUILD_CMD test --locked --target=${{ matrix.job.target }} ${{ steps.test-options.outputs.CARGO_TEST_OPTIONS}} 178 179- name : Create tarball 180id : package 181shell : bash 182run : | 183PKG_suffix=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) PKG_suffix=".zip" ;; esac; 184PKG_BASENAME=${{ needs.crate_metadata.outputs.name }}-v${{ needs.crate_metadata.outputs.version }}-${{ matrix.job.target }} 185PKG_NAME=${PKG_BASENAME}${PKG_suffix} 186echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_OUTPUT 187 188PKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/package" 189ARCHIVE_DIR="${PKG_STAGING}/${PKG_BASENAME}/" 190mkdir -p "${ARCHIVE_DIR}" 191 192# Binary 193cp "${{ steps.bin.outputs.BIN_PATH }}" "$ARCHIVE_DIR" 194 195# README and LICENSE files 196cp "README.md" "LICENSE-MIT" "LICENSE-APACHE" "$ARCHIVE_DIR" 197 198# Numbat prelude 199cp -r numbat/modules "$ARCHIVE_DIR" 200 201# base compressed package 202pushd "${PKG_STAGING}/" >/dev/null 203case ${{ matrix.job.target }} in 204*-pc-windows-*) 7z -y a "${PKG_NAME}" "${PKG_BASENAME}"/* | tail -2 ;; 205*) tar czf "${PKG_NAME}" "${PKG_BASENAME}"/* ;; 206esac; 207popd >/dev/null 208 209# Let subsequent steps know where to find the compressed package 210echo "PKG_PATH=${PKG_STAGING}/${PKG_NAME}" >> $GITHUB_OUTPUT 211 212- name : Create Debian package 213id : debian-package 214shell : bash 215if : startsWith(matrix.job.os, 'ubuntu') 216run : | 217COPYRIGHT_YEARS="2022 - "$(date "+%Y") 218DPKG_STAGING="${{ env.CICD_INTERMEDIATES_DIR }}/debian-package" 219DPKG_DIR="${DPKG_STAGING}/dpkg" 220mkdir -p "${DPKG_DIR}" 221 222DPKG_BASENAME=${{ needs.crate_metadata.outputs.name }} 223DPKG_CONFLICTS=${{ needs.crate_metadata.outputs.name }}-musl 224case ${{ matrix.job.target }} in *-musl) DPKG_BASENAME=${{ needs.crate_metadata.outputs.name }}-musl ; DPKG_CONFLICTS=${{ needs.crate_metadata.outputs.name }} ;; esac; 225DPKG_VERSION=${{ needs.crate_metadata.outputs.version }} 226 227unset DPKG_ARCH 228case ${{ matrix.job.target }} in 229aarch64-*-linux-*) DPKG_ARCH=arm64 ;; 230arm-*-linux-*hf) DPKG_ARCH=armhf ;; 231i686-*-linux-*) DPKG_ARCH=i686 ;; 232x86_64-*-linux-*) DPKG_ARCH=amd64 ;; 233*) DPKG_ARCH=notset ;; 234esac; 235 236DPKG_NAME="${DPKG_BASENAME}_${DPKG_VERSION}_${DPKG_ARCH}.deb" 237echo "DPKG_NAME=${DPKG_NAME}" >> $GITHUB_OUTPUT 238 239# Binary 240install -Dm755 "${{ steps.bin.outputs.BIN_PATH }}" "${DPKG_DIR}/usr/bin/${{ steps.bin.outputs.BIN_NAME }}" 241 242# README and LICENSE 243install -Dm644 "README.md" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/README.md" 244install -Dm644 "LICENSE-MIT" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/LICENSE-MIT" 245install -Dm644 "LICENSE-APACHE" "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/LICENSE-APACHE" 246 247# Numbat prelude 248mkdir -p "${DPKG_DIR}/usr/share/${DPKG_BASENAME}" 249cp -r numbat/modules "${DPKG_DIR}/usr/share/${DPKG_BASENAME}" 250 251cat > "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/copyright" <<EOF 252Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 253Upstream-Name: ${{ needs.crate_metadata.outputs.name }} 254Source: ${{ needs.crate_metadata.outputs.homepage }} 255 256Files: * 257Copyright: ${{ needs.crate_metadata.outputs.maintainer }} 258Copyright: $COPYRIGHT_YEARS ${{ needs.crate_metadata.outputs.maintainer }} 259License: Apache-2.0 or MIT 260 261License: Apache-2.0 262On Debian systems, the complete text of the Apache-2.0 can be found in the 263file /usr/share/common-licenses/Apache-2.0. 264 265License: MIT 266Permission is hereby granted, free of charge, to any 267person obtaining a copy of this software and associated 268documentation files (the "Software"), to deal in the 269Software without restriction, including without 270limitation the rights to use, copy, modify, merge, 271publish, distribute, sublicense, and/or sell copies of 272the Software, and to permit persons to whom the Software 273is furnished to do so, subject to the following 274conditions: 275. 276The above copyright notice and this permission notice 277shall be included in all copies or substantial portions 278of the Software. 279. 280THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 281ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 282TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 283PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 284SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 285CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 286OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 287IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 288DEALINGS IN THE SOFTWARE. 289EOF 290chmod 644 "${DPKG_DIR}/usr/share/doc/${DPKG_BASENAME}/copyright" 291 292# control file 293mkdir -p "${DPKG_DIR}/DEBIAN" 294cat > "${DPKG_DIR}/DEBIAN/control" <<EOF 295Package: ${DPKG_BASENAME} 296Version: ${DPKG_VERSION} 297Section: utils 298Priority: optional 299Maintainer: ${{ needs.crate_metadata.outputs.maintainer }} 300Homepage: ${{ needs.crate_metadata.outputs.homepage }} 301Architecture: ${DPKG_ARCH} 302Provides: ${{ needs.crate_metadata.outputs.name }} 303Conflicts: ${DPKG_CONFLICTS} 304Description: Statically typed programming language for scientific computations with first class support for physical dimensions and units 305EOF 306 307DPKG_PATH="${DPKG_STAGING}/${DPKG_NAME}" 308echo "DPKG_PATH=${DPKG_PATH}" >> $GITHUB_OUTPUT 309 310# build dpkg 311fakeroot dpkg-deb --build "${DPKG_DIR}" "${DPKG_PATH}" 312 313- name : "Artifact upload: tarball" 314uses : actions/upload-artifact@master 315with : 316name : ${{ steps.package.outputs.PKG_NAME }} 317path : ${{ steps.package.outputs.PKG_PATH }} 318 319- name : "Artifact upload: Debian package" 320uses : actions/upload-artifact@master 321if : steps.debian-package.outputs.DPKG_NAME 322with : 323name : ${{ steps.debian-package.outputs.DPKG_NAME }} 324path : ${{ steps.debian-package.outputs.DPKG_PATH }} 325 326- name : Check for release 327id : is-release 328shell : bash 329run : | 330unset IS_RELEASE ; if [[ $GITHUB_REF =~ ^refs/tags/v[0-9].* ]]; then IS_RELEASE='true' ; fi 331echo "IS_RELEASE=${IS_RELEASE}" >> $GITHUB_OUTPUT 332 333- name : Publish archives and packages 334uses : softprops/action-gh-release@v1 335if : steps.is-release.outputs.IS_RELEASE 336with : 337files : | 338${{ steps.package.outputs.PKG_PATH }} 339${{ steps.debian-package.outputs.DPKG_PATH }} 340env : 341GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}