diff --git a/.cargo/config.toml b/.cargo/config.toml new file mode 100644 index 0000000000..df8e1a5368 --- /dev/null +++ b/.cargo/config.toml @@ -0,0 +1,2 @@ +[target.aarch64-unknown-linux-musl] +rustflags = ["-C", "link-arg=-lgcc"] diff --git a/.github/workflows/build-all.yml b/.github/workflows/build-all.yml index 2ba2c45f11..11ca26cb17 100644 --- a/.github/workflows/build-all.yml +++ b/.github/workflows/build-all.yml @@ -9,23 +9,31 @@ jobs: name: ${{ matrix.os-name }}-build runs-on: ${{ matrix.os }} container: ${{ matrix.container }} - env: - GHC_VERSION: '9.8.2' - - defaults: run: shell: bash strategy: matrix: - os: ['windows-latest', 'ubuntu-latest', 'macos-12', 'macos-latest'] + os: [ 'LinuxARM', 'windows-latest', 'ubuntu-latest', 'macos-12', 'macos-latest'] include: + - os: LinuxARM + os-name: Linux-arm + project-file: cabal.project.ci.linux + ghc: '9.8.2' + rust-features: jemalloc + - os: ubuntu-latest os-name: Linux container: fossa/haskell-static-alpine:ghc-9.8.2 project-file: cabal.project.ci.linux ghc: '9.8.2' + # Linux builds are run in Alpine, which builds them statically; + # using jemalloc reduces the performance impact of this + # over the default libc allocator (which performs very poorly in static builds). + # Non-Linux environments generally don't need `jemalloc` + # and in particular Windows doesn't support it + rust-features: jemalloc # macos-latest pointed at macos-12 this before it was changed to ARM. - os: macos-12 @@ -59,47 +67,52 @@ jobs: - uses: haskell-actions/setup@v2 id: setup-haskell name: Setup ghc/cabal (non-alpine) - if: ${{ !contains(matrix.os, 'ubuntu') }} + if: ${{ !contains(matrix.os-name, 'Linux') }} with: ghc-version: ${{ matrix.ghc }} cabal-version: '3.10.3.0' # Set up Rust. # This action installs the 'minimal' profile. + # Even on Linux ARM this is necessary because rust-cache uses it. - uses: dtolnay/rust-toolchain@stable - name: Install additional Rust tooling + if: ${{ matrix.os != 'LinuxARM' }} uses: taiki-e/install-action@v2 with: tool: nextest - uses: Swatinem/rust-cache@v2 + with: + prefix-key: ${{ matrix.os }} + # The home directory inside containers is different than the one outside of them. + # LinuxARM needs this for its caching to work inside haskell-static-alpine. + cache-directories: ${{ runner.temp }}/_github_home/.cargo - name: Debugging information run: | ghc --version || echo "no ghc" cabal --version || echo "no cabal" ghcup --version || echo "no ghcup" - rustc -V || echo "no rustc" - cargo -V || echo "no cargo" - - # Linux builds are run in Alpine, which builds them statically; - # using jemalloc reduces the performance impact of this - # over the default libc allocator (which performs very poorly in static builds). - - name: Build Rust dependencies (Linux) - if: ${{ matrix.os-name == 'linux' }} - run: cargo build --features jemalloc --release - - # Non-Linux environments generally don't need `jemalloc` - # and in particular Windows doesn't support it. - - name: Build Rust dependencies (non-Linux) - if: ${{ matrix.os-name != 'linux' }} - run: cargo build --release + + - name: Build Rust dependencies + if: ${{ matrix.os != 'LinuxARM' }} + env: + RUST_FEATURES: ${{ matrix.rust-features }} + run: | + cargo build ${RUST_FEATURES:+--features $RUST_FEATURES} --release # Run tests in release mode to reduce the need for rebuilds. - name: Test Rust dependencies + if: ${{ matrix.os != 'LinuxARM' }} run: cargo nextest run --release + - name: Validate diagnose commands run on the platform + if: ${{ matrix.os != 'LinuxARM' }} + run: | + cargo run --release --bin diagnose -- walk --trace-spans none --trace-level info + - name: Ensure git ownership check does not lead to compiler error run: git config --global --add safe.directory "$GITHUB_WORKSPACE" @@ -114,48 +127,39 @@ jobs: # We compute the cache key based on the solved install plan instead of just # hashing the `.cabal` file, since there are many kinds of changes that will # cause `.cabal` to change (e.g. adding new source modules). - - name: Compute cache key + - name: Compute cache key (not ARM Linux) + if: ${{ matrix.os != 'LinuxARM' }} id: compute-cache-key - env: - RUNNER_OS: ${{ runner.os }} - run: | - cabal --project-file=${{ matrix.project-file }} update - cabal --project-file=${{ matrix.project-file }} build --dry-run - cat dist-newstyle/cache/plan.json | jq '."install-plan"[]."id"' | sort > /tmp/cabal-cache-key - echo "Install plan:" - cat /tmp/cabal-cache-key - - if [ "$RUNNER_OS" = "macOS" ]; then - PLAN_SUM=$(shasum -a256 /tmp/cabal-cache-key) - else - PLAN_SUM=$(sha256sum /tmp/cabal-cache-key) - fi + run: ./.github/workflows/scripts/compute_cache_key.sh ${{ runner.os }} ${{ matrix.project-file }} - export CABAL_CACHE_KEY=$(echo $PLAN_SUM | awk '{print $1}') - echo "Cabal cache key: $CABAL_CACHE_KEY" - echo "cabal-cache-key=$CABAL_CACHE_KEY" >> $GITHUB_OUTPUT + - name: Compute Cache Key (Linux Arm) + if: ${{ matrix.os == 'LinuxARM' }} + id: compute-cache-key-arm + uses: docker://fossa/haskell-static-alpine:ghc-9.8.2 + with: + args: ./.github/workflows/scripts/compute_cache_key.sh ${{ runner.os }} ${{ matrix.project-file }} - # Build FOSSA CLI. + # The home directory inside a github container run during a step is different than one run outside of it. + # This is why there is special logic for 'LinuxARM'. + # Its builds run inside a container but are cached by an action outside of it.. - uses: actions/cache@v4 name: Cache cabal store with: - path: ${{ steps.setup-haskell.outputs.cabal-store || '~/.local/state/cabal' }} - key: ${{ matrix.os-name }}-${{ matrix.ghc }}-cabal-cache-${{ steps.compute-cache-key.outputs.cabal-cache-key }} + path: ${{ steps.setup-haskell.outputs.cabal-store || ( matrix.os == 'LinuxARM' && format('{0}/_github_home/.local/state/cabal', runner.temp) || '~/.local/state/cabal') }} + key: ${{ matrix.os-name }}-${{ matrix.ghc }}-cabal-cache-${{ steps.compute-cache-key.outputs.cabal-cache-key || steps.compute-cache-key-arm.outputs.cabal-cache-key }} restore-keys: | ${{ matrix.os-name }}-${{ matrix.ghc }}-cabal-cache- ${{ matrix.os-name }}-${{ matrix.ghc }}- - ${{ matrix.os-name }}- - uses: actions/cache@v4 name: Cache dist-newstyle with: path: ${{ github.workspace }}/dist-newstyle - key: ${{ matrix.os-name }}-${{ env.GHC_VERSION }}-dist-newstyle-${{ github.sha }} + key: ${{ matrix.os-name }}-${{ matrix.ghc }}-dist-newstyle-${{ github.sha }} restore-keys: | - ${{ matrix.os-name }}-${{ env.GHC_VERSION }}-dist-newstyle-${{ env.parent_commit }} - ${{ matrix.os-name }}-${{ env.GHC_VERSION }}-dist-newstyle- - ${{ matrix.os-name }}-${{ env.GHC_VERSION }}- - ${{ matrix.os-name }}- + ${{ matrix.os-name }}-${{ matrix.ghc }}-dist-newstyle-${{ env.parent_commit }} + ${{ matrix.os-name }}-${{ matrix.ghc }}-dist-newstyle- + ${{ matrix.os-name }}-${{ matrix.ghc }}- - name: Update vendored binaries run: | @@ -164,38 +168,22 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.BASIS_ACCESS_TOKEN }} - - name: Build test data - run: | - make build-test-data + - name: Build and Unit Test (Linux ARM) + if: ${{ matrix.os == 'LinuxARM' }} + uses: docker://fossa/haskell-static-alpine:ghc-9.8.2 + with: + args: ./.github/workflows/scripts/build-arm.sh ${{ runner.os }} ${{ matrix.project-file }} ${{ matrix.rust-features }} - - name: Build - # Occasionally, we run out of memory on the build process. - # Since cabal uses incremental compilation, we can retry from where we left off - # by simply re-running cabal if we fail. - env: - RUN_CMD: cabal build --project-file=${{ matrix.project-file }} all - run: | - : # With dist-newstyle caches: - : # Cabal mainly knows to recompile based on changes to files. - : # Tagging in git doesn't reliably change a file in a fixed location that cabal/GHC can track to indicate that there's a new tag. - : # For our release process, we merge to master, which builds (and may store a dist-newstyle cache), then push a release tag. - : # During the tag build, cabal/GHC may not realize that they have to rebuild the Version.hs file because the tag is invisible to it. - : # This line adds a unique comment to our version source file to prompt cabal/GHC to rebuild Version.hs unconditionally. - echo "{- $RANDOM$RANDOM$RANDOM -}" >> src/App/Version.hs - cabal update - $RUN_CMD || $RUN_CMD - - - name: Run unit tests - run: | - cabal test --project-file=${{ matrix.project-file }} unit-tests - - - name: Validate diagnose commands run on the platform - run: | - cargo run --bin diagnose -- walk --trace-spans none --trace-level info + - name: Build and Unit Test + if: ${{ matrix.os != 'LinuxARM' }} + run: ./.github/workflows/scripts/build.sh ${{ runner.os }} ${{ matrix.project-file }} # Test cabal-install + # TODO: This has apparently not been turned on for a while since no matrix.os contains 'linux'. + # When I make it function it causes an error. + # This is something I need to look into in the future. - name: Test Cabal Install (Linux) - if: ${{ contains(matrix.os, 'linux') }} + if: ${{ matrix.os == 'linux' }} run: cabal install --overwrite-policy=always --project=${{ matrix.project-file }} --ghc-options="-Wwarn" # Save artifacts. @@ -326,20 +314,22 @@ jobs: if: ${{ github.ref_type == 'tag' }} uses: sigstore/cosign-installer@v3.4.0 - - name: Sign Release (Linux) + - name: Sign and Verify Release (Linux) if: ${{ github.ref_type == 'tag' }} run: | cosign version - cosign sign-blob --yes --bundle "Linux-binaries/fossa.bundle" "Linux-binaries/fossa" - cosign sign-blob --yes --bundle "Linux-binaries/diagnose.bundle" "Linux-binaries/diagnose" - cosign sign-blob --yes --bundle "Linux-binaries/millhone.bundle" "Linux-binaries/millhone" - - name: Verify Signatures - if: ${{ github.ref_type == 'tag' }} - run: | - cosign verify-blob --bundle "Linux-binaries/fossa.bundle" --certificate-oidc-issuer "https://token.actions.githubusercontent.com" --certificate-identity "https://github.com/$GITHUB_WORKFLOW_REF" "Linux-binaries/fossa" - cosign verify-blob --bundle "Linux-binaries/diagnose.bundle" --certificate-oidc-issuer "https://token.actions.githubusercontent.com" --certificate-identity "https://github.com/$GITHUB_WORKFLOW_REF" "Linux-binaries/diagnose" - cosign verify-blob --bundle "Linux-binaries/millhone.bundle" --certificate-oidc-issuer "https://token.actions.githubusercontent.com" --certificate-identity "https://github.com/$GITHUB_WORKFLOW_REF" "Linux-binaries/millhone" + for linux_kind in 'Linux' 'Linux-arm' + do + cosign sign-blob --yes --bundle "$linux_kind-binaries/fossa.bundle" "$linux_kind-binaries/fossa" + cosign sign-blob --yes --bundle "$linux_kind-binaries/diagnose.bundle" "$linux_kind-binaries/diagnose" + cosign sign-blob --yes --bundle "$linux_kind-binaries/millhone.bundle" "$linux_kind-binaries/millhone" + + cosign verify-blob --bundle "$linux_kind-binaries/fossa.bundle" --certificate-oidc-issuer "https://token.actions.githubusercontent.com" --certificate-identity "https://github.com/$GITHUB_WORKFLOW_REF" "$linux_kind-binaries/fossa" + cosign verify-blob --bundle "$linux_kind-binaries/diagnose.bundle" --certificate-oidc-issuer "https://token.actions.githubusercontent.com" --certificate-identity "https://github.com/$GITHUB_WORKFLOW_REF" "$linux_kind-binaries/diagnose" + cosign verify-blob --bundle "$linux_kind-binaries/millhone.bundle" --certificate-oidc-issuer "https://token.actions.githubusercontent.com" --certificate-identity "https://github.com/$GITHUB_WORKFLOW_REF" "$linux_kind-binaries/millhone" + + done # This uses names compatible with our install script. # @@ -356,12 +346,20 @@ jobs: LINUX_DIAGNOSE_ZIP_PATH: "release/diagnose_${{ steps.get-version.outputs.VERSION }}_linux_amd64.zip" LINUX_MILLHONE_TAR_PATH: "release/millhone_${{ steps.get-version.outputs.VERSION }}_linux_amd64.tar" LINUX_MILLHONE_ZIP_PATH: "release/millhone_${{ steps.get-version.outputs.VERSION }}_linux_amd64.zip" + LINUX_ARM_FOSSA_TAR_PATH: "release/fossa_${{ steps.get-version.outputs.VERSION }}_linux_arm64.tar" + LINUX_ARM_FOSSA_ZIP_PATH: "release/fossa_${{ steps.get-version.outputs.VERSION }}_linux_arm64.zip" + LINUX_ARM_DIAGNOSE_TAR_PATH: "release/diagnose_${{ steps.get-version.outputs.VERSION }}_linux_arm64.tar" + LINUX_ARM_DIAGNOSE_ZIP_PATH: "release/diagnose_${{ steps.get-version.outputs.VERSION }}_linux_arm64.zip" + LINUX_ARM_MILLHONE_TAR_PATH: "release/millhone_${{ steps.get-version.outputs.VERSION }}_linux_arm64.tar" + LINUX_ARM_MILLHONE_ZIP_PATH: "release/millhone_${{ steps.get-version.outputs.VERSION }}_linux_arm64.zip" + run: | mkdir release ls -R - chmod +x Linux-binaries/* + chmod +x Linux*-binaries/* + zip -j "$LINUX_FOSSA_ZIP_PATH" Linux-binaries/fossa zip -j "$LINUX_DIAGNOSE_ZIP_PATH" Linux-binaries/diagnose zip -j "$LINUX_MILLHONE_ZIP_PATH" Linux-binaries/millhone @@ -369,6 +367,13 @@ jobs: tar --create --verbose --file "$LINUX_DIAGNOSE_TAR_PATH" --directory Linux-binaries diagnose tar --create --verbose --file "$LINUX_MILLHONE_TAR_PATH" --directory Linux-binaries millhone + zip -j "$LINUX_ARM_FOSSA_ZIP_PATH" Linux-arm-binaries/fossa + zip -j "$LINUX_ARM_DIAGNOSE_ZIP_PATH" Linux-arm-binaries/diagnose + zip -j "$LINUX_ARM_MILLHONE_ZIP_PATH" Linux-arm-binaries/millhone + tar --create --verbose --file "$LINUX_ARM_FOSSA_TAR_PATH" --directory Linux-arm-binaries fossa + tar --create --verbose --file "$LINUX_ARM_DIAGNOSE_TAR_PATH" --directory Linux-arm-binaries diagnose + tar --create --verbose --file "$LINUX_ARM_MILLHONE_TAR_PATH" --directory Linux-arm-binaries millhone + if [ "$GITHUB_REF_TYPE" = "tag" ]; then tar --append --file "$LINUX_FOSSA_TAR_PATH" --directory Linux-binaries fossa.bundle tar --append --file "$LINUX_DIAGNOSE_TAR_PATH" --directory Linux-binaries diagnose.bundle @@ -376,12 +381,24 @@ jobs: zip -j "$LINUX_FOSSA_ZIP_PATH" Linux-binaries/fossa.bundle zip -j "$LINUX_DIAGNOSE_ZIP_PATH" Linux-binaries/diagnose.bundle zip -j "$LINUX_MILLHONE_ZIP_PATH" Linux-binaries/millhone.bundle + + tar --append --file "$LINUX_ARM_FOSSA_TAR_PATH" --directory Linux-arm-binaries fossa.bundle + tar --append --file "$LINUX_ARM_DIAGNOSE_TAR_PATH" --directory Linux-arm-binaries diagnose.bundle + tar --append --file "$LINUX_ARM_MILLHONE_TAR_PATH" --directory Linux-arm-binaries millhone.bundle + zip -j "$LINUX_ARM_FOSSA_ZIP_PATH" Linux-arm-binaries/fossa.bundle + zip -j "$LINUX_ARM_DIAGNOSE_ZIP_PATH" Linux-arm-binaries/diagnose.bundle + zip -j "$LINUX_ARM_MILLHONE_ZIP_PATH" Linux-arm-binaries/millhone.bundle + fi gzip "$LINUX_FOSSA_TAR_PATH" gzip "$LINUX_DIAGNOSE_TAR_PATH" gzip "$LINUX_MILLHONE_TAR_PATH" + gzip "$LINUX_ARM_FOSSA_TAR_PATH" + gzip "$LINUX_ARM_DIAGNOSE_TAR_PATH" + gzip "$LINUX_ARM_MILLHONE_TAR_PATH" + chmod +x macOS-intel-binaries/* zip -j release/fossa_${{ steps.get-version.outputs.VERSION }}_darwin_amd64.zip macOS-intel-binaries/fossa zip -j release/diagnose_${{ steps.get-version.outputs.VERSION }}_darwin_amd64.zip macOS-intel-binaries/diagnose @@ -400,11 +417,11 @@ jobs: # We have to run from within the release dir so that "release" isn't prepended to the relative path of the zip file. run: | cd release - sha256sum --binary "fossa_${{ steps.get-version.outputs.VERSION }}_linux_amd64.zip" > "fossa_${{ steps.get-version.outputs.VERSION }}_linux_amd64.zip.sha256" - sha256sum --binary "fossa_${{ steps.get-version.outputs.VERSION }}_linux_amd64.tar.gz" > "fossa_${{ steps.get-version.outputs.VERSION }}_linux_amd64.tar.gz.sha256" - sha256sum --binary "fossa_${{ steps.get-version.outputs.VERSION }}_darwin_amd64.zip" > "fossa_${{ steps.get-version.outputs.VERSION }}_darwin_amd64.zip.sha256" - sha256sum --binary "fossa_${{ steps.get-version.outputs.VERSION }}_darwin_arm64.zip" > "fossa_${{ steps.get-version.outputs.VERSION }}_darwin_arm64.zip.sha256" - sha256sum --binary "fossa_${{ steps.get-version.outputs.VERSION }}_windows_amd64.zip" > "fossa_${{ steps.get-version.outputs.VERSION }}_windows_amd64.zip.sha256" + + for f in fossa*.zip fossa*.tar.gz + do + sha256sum --binary "$f" > "$f.sha256" + done echo "Sanity-checking the checksums." diff --git a/.github/workflows/scripts/build-arm.sh b/.github/workflows/scripts/build-arm.sh new file mode 100755 index 0000000000..0fdc5a218c --- /dev/null +++ b/.github/workflows/scripts/build-arm.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env sh + +set -e +set -x + +if [ $# -lt 2 ] ; then + echo "Usage: ./build-arm.sh [FEATURES]" + exit 1 +fi + +RUNNER_OS=$1 +PROJECT_FILE=$2 +FEATURES=$3 + +# Install rust tooling +curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal +. "/home/runner/.cargo/env" + +rustc -V +cargo -V + +# Build Rust binaries +cargo build ${FEATURES:+--features $FEATURES} --release + +cargo test --release + +# Validate that diagnose runs +cargo run --release --bin diagnose -- walk --trace-spans none --trace-level info + +# Now do Haskell things +./.github/workflows/scripts/build.sh "$RUNNER_OS" "$PROJECT_FILE" diff --git a/.github/workflows/scripts/build.sh b/.github/workflows/scripts/build.sh new file mode 100755 index 0000000000..5bf6721f9a --- /dev/null +++ b/.github/workflows/scripts/build.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env sh + +set -e +set -x + +if [ $# -lt 2 ] ; then + echo "Usage: ./build.sh " + exit 1 +fi + +RUNNER_OS=$1 +PROJECT_FILE=$2 + +make build-test-data + +# Does this need to run in the container? +# It normally runs outside. +git config --global --add safe.directory "$GITHUB_WORKSPACE" + +# With dist-newstyle caches: +# Cabal mainly knows to recompile based on changes to files. +# Tagging in git doesn't reliably change a file in a fixed location that cabal/GHC can track to indicate that there's a new tag. +# For our release process, we merge to master, which builds (and may store a dist-newstyle cache), then push a release tag. +# During the tag build, cabal/GHC may not realize that they have to rebuild the Version.hs file because the tag is invisible to it. +# This line adds a comment to our version source file to prompt cabal/GHC to rebuild Version.hs. +echo "{- $GITHUB_RUN_ID -}" >> src/App/Version.hs +cabal update +cabal build --project-file="$PROJECT_FILE" all +cabal test --project-file="$PROJECT_FILE" unit-tests + +# Todo: Bring this back. +# Test cabal-install. +# This check ensures that QuickImport can use spectrometer as a library. +# if [ "$RUNNER_OS" = 'Linux' ] ; then +# cabal install --overwrite-policy=always --project-file="$PROJECT_FILE" --ghc-options="-Wwarn" +# fi diff --git a/.github/workflows/scripts/compute_cache_key.sh b/.github/workflows/scripts/compute_cache_key.sh new file mode 100755 index 0000000000..9ade3ba058 --- /dev/null +++ b/.github/workflows/scripts/compute_cache_key.sh @@ -0,0 +1,34 @@ +#!/usr/bin/env sh + +set -e +set -x + +if [ $# -lt 2 ] ; then + echo "Usage: ./compute_cache_key " + exit 1 +fi + +RUNNER_OS=$1 +PROJECT_FILE=$2 + +cabal --project-file="$PROJECT_FILE" update +cabal --project-file="$PROJECT_FILE" build --dry-run +jq '."install-plan"[]."id"' < dist-newstyle/cache/plan.json | sort > /tmp/cabal-cache-key +echo "Install plan:" +cat /tmp/cabal-cache-key + +if [ "$RUNNER_OS" = "macOS" ]; then + PLAN_SUM=$(shasum -a256 /tmp/cabal-cache-key) +else + PLAN_SUM=$(sha256sum /tmp/cabal-cache-key) +fi + +CABAL_CACHE_KEY="$(echo "$PLAN_SUM" | awk '{print $1}')" +export CABAL_CACHE_KEY +echo "Cabal cache key: $CABAL_CACHE_KEY" +echo "cabal-cache-key=$CABAL_CACHE_KEY" >> "$GITHUB_OUTPUT" + +echo "Home dotfiles in container: $(ls -al ~/.*)" + +# Cleanup. Restoring this cache seems to fail if the directory already exists. +rm -rf dist-newstyle diff --git a/Cargo.lock b/Cargo.lock index 65bd116492..cb67f26984 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1796,7 +1796,7 @@ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" [[package]] name = "snippets" version = "0.1.3" -source = "git+https://github.com/fossas/foundation-libs#4bc3762e73f371717566fb075d02e1d25b21146e" +source = "git+https://github.com/fossas/lib-snippets?tag=v0.1.3#d0b2cd39b48793b36ea6860b7b284054e270cdb9" dependencies = [ "base64 0.21.7", "derivative", diff --git a/Cargo.toml b/Cargo.toml index 9dd2b21d04..a975717b2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,3 +17,7 @@ resolver = "2" [profile.release] lto = "fat" strip = true + +# There is additional configuration in .cargo/config.toml. +# It is used for building on aarch64-unknown-linux-musl. +# More context on the split here: https://github.com/rust-lang/cargo/issues/12738 \ No newline at end of file diff --git a/Changelog.md b/Changelog.md index 4989fe88c8..8a116e2681 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,9 @@ # FOSSA CLI Changelog +## 3.9.32 + +- Platform Support: Add a binary for ARM64 Linux environments. ([#1465](https://github.com/fossas/fossa-cli/pull/1465)) + ## 3.9.31 - Resolve an issue parsing toml configuration files. ([#1459](https://github.com/fossas/fossa-cli/pull/1459)) diff --git a/extlib/millhone/Cargo.toml b/extlib/millhone/Cargo.toml index b0abb1c70d..695a3fc350 100644 --- a/extlib/millhone/Cargo.toml +++ b/extlib/millhone/Cargo.toml @@ -12,7 +12,7 @@ tikv-jemallocator = { version = "0.5.4", optional = true } clap = { version = "4.3.21", features = ["derive", "env", "cargo"] } stable-eyre = "0.2.2" srclib = { version = "*", git = "https://github.com/fossas/foundation-libs" } -snippets = { version = "0.1.3", git = "https://github.com/fossas/foundation-libs", features = ["lang-all"] } +snippets = { version = "0.1.3", tag = "v0.1.3", git = "https://github.com/fossas/lib-snippets", features = ["lang-all"] } traceconf = { git = "https://github.com/fossas/foundation-libs", version = "1.1.0" } serde = { version = "1.0.183", features = ["derive"] } thiserror = "1.0.46" diff --git a/install-latest.sh b/install-latest.sh index 2362fb4ed8..40b9781abb 100755 --- a/install-latest.sh +++ b/install-latest.sh @@ -66,6 +66,7 @@ is_supported_platform() { darwin/amd64) found=0 ;; darwin/arm64) found=0 ;; linux/amd64) found=0 ;; + linux/arm64) found=0 ;; esac return $found } @@ -119,7 +120,16 @@ adjust_arch() { # adjust archive name based on ARCH true } - +arch_version_check() { + # TODO: Make this version correct before merging. + if [ "${OS}/${ARCH}" = "linux/arm64" ] && version_less_than "${VERSION}" '3.9.32' + then + echo "There is no linux/arm64 binary for version $VERSION." + echo "Please select a version that is at least version 3.9.32" + exit 1 + fi + true +} cat /dev/null < Q Exp embedFileIfExists inputPath = do skipEmbedEnvVar <- runIO $ lookupEnv "FOSSA_SKIP_EMBED_FILE_IN_HLS" - case (skipEmbedEnvVar, parseRelFile inputPath) of + -- During some commands (like cabal install) the working directory may not + -- be the same as the root of this project. + -- makeRelativeToProject takes a relative path and roots it in the highest directory + -- a .cabal file is found and returns an absolute path. + inputPath' <- makeRelativeToProject inputPath + case (skipEmbedEnvVar, parseAbsFile inputPath') of (Just _, _) -> do pure (LitE $ StringL "") (_, Just path) -> do diff --git a/test/App/Fossa/PathDependencySpec.hs b/test/App/Fossa/PathDependencySpec.hs index 561f9988f5..bfa33f3a60 100644 --- a/test/App/Fossa/PathDependencySpec.hs +++ b/test/App/Fossa/PathDependencySpec.hs @@ -11,6 +11,7 @@ import Control.Algebra (Has) import Control.Effect.FossaApiClient (FossaApiClientF (..), PackageRevision (PackageRevision)) import Data.Flag (toFlag) import Data.Set qualified as Set +import Data.String.Conversion (toText) import Data.Text (Text) import DepTypes ( DepEnvironment (EnvTesting), @@ -41,10 +42,11 @@ absPathOfSpec = describe "absPathOfSpec" $ do mkPathSpec cwd "../" isAbsDir mkPathSpec cwd "./" isAbsDir - mkPathSpec cwd "../fossa-cli" isAbsDir - mkPathSpec cwd "../fossa-cli/" isAbsDir - mkPathSpec cwd "../fossa-cli/test" isAbsDir - mkPathSpec cwd "../fossa-cli/test/" isAbsDir + let currentPathRel = "../" <> (toText . toFilePath . dirname $ cwd) + mkPathSpec cwd currentPathRel isAbsDir + mkPathSpec cwd (currentPathRel <> "/") isAbsDir + mkPathSpec cwd (currentPathRel <> "/test") isAbsDir + mkPathSpec cwd (currentPathRel <> "/test/") isAbsDir mkPathSpec cwd "./test" isAbsDir mkPathSpec cwd "./test/" isAbsDir diff --git a/vendor_download.sh b/vendor_download.sh index 8a3c0b9188..6ee96df642 100755 --- a/vendor_download.sh +++ b/vendor_download.sh @@ -51,11 +51,20 @@ case "$(uname -s)" in ;; Linux) - ASSET_POSTFIX="linux" - THEMIS_ASSET_POSTFIX="linux-amd64" - LERNIE_ASSET_POSTFIX="x86_64-linux" - ;; + case "$(uname -m)" in + aarch64) + ASSET_POSTFIX="linux" + THEMIS_ASSET_POSTFIX="linux-arm64" + LERNIE_ASSET_POSTFIX="aarch64-linux" + ;; + *) + ASSET_POSTFIX="linux" + THEMIS_ASSET_POSTFIX="linux-amd64" + LERNIE_ASSET_POSTFIX="x86_64-linux" + ;; + esac + ;; *) echo "Warn: Assuming $(uname -s) is Windows" ASSET_POSTFIX="windows.exe"