Justfile and release workflow improvements

This commit is contained in:
Filip Tibell 2023-09-25 15:43:32 -05:00
parent 5f7bf6d3f2
commit dd1db5dcab
No known key found for this signature in database
3 changed files with 133 additions and 61 deletions

View file

@ -10,9 +10,6 @@ defaults:
run: run:
shell: bash shell: bash
env:
CARGO_TARGET_DIR: output
jobs: jobs:
init: init:
name: Init name: Init
@ -33,6 +30,7 @@ jobs:
build: build:
needs: ["init"] needs: ["init"]
strategy: strategy:
fail-fast: false
matrix: matrix:
include: include:
- name: Windows x86_64 - name: Windows x86_64
@ -71,6 +69,9 @@ jobs:
with: with:
targets: ${{ matrix.cargo-target }} targets: ${{ matrix.cargo-target }}
- name: Install Just
uses: extractions/setup-just@v1
- name: Install build tooling (aarch64-unknown-linux-gnu) - name: Install build tooling (aarch64-unknown-linux-gnu)
if: matrix.cargo-target == 'aarch64-unknown-linux-gnu' if: matrix.cargo-target == 'aarch64-unknown-linux-gnu'
run: | run: |
@ -79,26 +80,12 @@ jobs:
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
- name: Build binary - name: Build binary
run: | run: just build --locked --release --target ${{ matrix.cargo-target }}
cargo build \
--locked --release --all-features \
--target ${{ matrix.cargo-target }}
- name: Create binary archive - name: Create release archive
run: | run: just zip-release ${{ matrix.cargo-target }}
mkdir -p staging
if [ "${{ matrix.runner-os }}" = "windows-latest" ]; then
cp "output/${{ matrix.cargo-target }}/release/lune.exe" staging/
cd staging
7z a ../release.zip *
else
cp "output/${{ matrix.cargo-target }}/release/lune" staging/
cd staging
chmod +x lune
zip ../release.zip *
fi
- name: Upload binary artifact - name: Upload release artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: ${{ matrix.artifact-name }} name: ${{ matrix.artifact-name }}
@ -109,38 +96,19 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: ["init", "build"] needs: ["init", "build"]
steps: steps:
- name: Download binaries - name: Checkout repository
uses: actions/checkout@v4
- name: Install Just
uses: extractions/setup-just@v1
- name: Download releases
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
path: ./binaries path: ./releases
- name: Discover binaries - name: Unpack releases
run: | run: just unpack-releases "./releases"
cd ./binaries
echo ""
echo "Binaries dir:"
ls -lhrt
echo ""
echo "Searching for zipped releases..."
for DIR in * ; do
if [ -d "$DIR" ]; then
cd "$DIR"
for FILE in * ; do
if [ ! -d "$FILE" ]; then
if [ "$FILE" = "release.zip" ]; then
echo "Found zipped release '$DIR'"
mv "$FILE" "../$DIR.zip"
rm -rf "../$DIR/"
fi
fi
done
cd ..
fi
done
echo ""
echo "Binaries dir:"
ls -lhrt
cd ..
- name: Create release - name: Create release
uses: softprops/action-gh-release@v1 uses: softprops/action-gh-release@v1
@ -150,5 +118,5 @@ jobs:
name: ${{ needs.init.outputs.version }} name: ${{ needs.init.outputs.version }}
tag_name: v${{ needs.init.outputs.version }} tag_name: v${{ needs.init.outputs.version }}
fail_on_unmatched_files: true fail_on_unmatched_files: true
files: ./binaries/*.zip files: ./releases/*.zip
draft: true draft: true

7
.gitignore vendored
View file

@ -6,7 +6,14 @@
# Autogenerated dirs # Autogenerated dirs
/bin /bin
/out
/target /target
/staging
/**/bin
/**/out
/**/target
/**/staging
# Autogenerated files # Autogenerated files

117
.justfile
View file

@ -1,22 +1,119 @@
# Run an individual test using the Lune CLI EXT := if os() == "windows" { ".exe" } else { "" }
run-test TEST_NAME: CWD := invocation_directory()
cargo run -- "tests/{{TEST_NAME}}" BIN_NAME := "lune"
# Default hidden recipe for listing other recipes + cwd
[no-cd]
[no-exit-message]
[private]
default:
#!/usr/bin/env bash
set -euo pipefail
printf "Current directory:\n {{CWD}}\n"
just --list
# Builds the Lune CLI binary
[no-exit-message]
build *ARGS:
#!/usr/bin/env bash
set -euo pipefail
cargo build --bin {{BIN_NAME}} {{ARGS}}
# Run an individual file using the Lune CLI # Run an individual file using the Lune CLI
run-file FILE_NAME: [no-exit-message]
cargo run -- "{{FILE_NAME}}" run FILE_PATH:
#!/usr/bin/env bash
set -euo pipefail
cargo run --bin {{BIN_NAME}} -- "{{FILE_PATH}}"
# Run tests for the Lune library # Run tests for the Lune library
test: [no-exit-message]
cargo test --lib test *ARGS:
#!/usr/bin/env bash
set -euo pipefail
cargo test --lib -- {{ARGS}}
# Run tests for the Lune binary
[no-exit-message]
test-bin *ARGS:
#!/usr/bin/env bash
set -euo pipefail
cargo test --bin {{BIN_NAME}} -- {{ARGS}}
# Apply formatting for all Rust & Luau files
[no-exit-message]
fmt:
#!/usr/bin/env bash
set -euo pipefail
stylua scripts tests types \
--glob "tests/**/*.luau" \
--glob "!tests/roblox/rbx-test-files/**"
cargo fmt
# Check formatting for all Rust & Luau files # Check formatting for all Rust & Luau files
[no-exit-message]
fmt-check: fmt-check:
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
stylua scripts --check stylua scripts tests types \
stylua types --check
stylua tests --check \
--glob "tests/**/*.luau" \ --glob "tests/**/*.luau" \
--glob "!tests/roblox/rbx-test-files/**" --glob "!tests/roblox/rbx-test-files/**"
cargo fmt --check cargo fmt --check
# Zips up the built binary into a single zip file
[no-exit-message]
zip-release TARGET_TRIPLE:
#!/usr/bin/env bash
set -euo pipefail
rm -rf staging
rm -rf release.zip
mkdir -p staging
cp "target/{{TARGET_TRIPLE}}/release/{{BIN_NAME}}{{EXT}}" staging/
cd staging
if [ "{{os_family()}}" = "windows" ]; then
7z a ../release.zip *
else
chmod +x {{BIN_NAME}}
zip ../release.zip *
fi
cd "{{CWD}}"
rm -rf staging
# Used in GitHub workflow to move per-matrix release zips
[no-exit-message]
[private]
unpack-releases RELEASES_DIR:
#!/usr/bin/env bash
set -euo pipefail
#
if [ ! -d "{{RELEASES_DIR}}" ]; then
echo "Releases directory is missing"
exit 1
fi
#
cd "{{RELEASES_DIR}}"
echo ""
echo "Releases dir:"
ls -lhrt
echo ""
echo "Searching for zipped releases..."
#
for DIR in * ; do
if [ -d "$DIR" ]; then
cd "$DIR"
for FILE in * ; do
if [ ! -d "$FILE" ]; then
if [ "$FILE" = "release.zip" ]; then
echo "Found zipped release '$DIR'"
mv "$FILE" "../$DIR.zip"
rm -rf "../$DIR/"
fi
fi
done
cd ..
fi
done
#
echo ""
echo "Releases dir:"
ls -lhrt