From 944b3e2d4346f0b0f441d4d2bb6779f0004c4298 Mon Sep 17 00:00:00 2001 From: Yusuke Tsutsumi Date: Sun, 31 Mar 2024 23:14:11 -0700 Subject: [PATCH] fix: unit tests for aarch64 architetures (#54) tome unit tests we're not working for aarch64, which seem to due to Python's availability on each platform. Expanding the workflow file with help from @zph to expand testing surface. --- .github/workflows/linux-build.yml | 45 ------------ .github/workflows/main.yml | 68 +++++++++++++++++++ .github/workflows/osx-build.yml | 38 ----------- example/file_example | 18 +++-- example/test_files/file_example_no_completion | 2 +- src/lib_tests.rs | 2 +- 6 files changed, 82 insertions(+), 91 deletions(-) delete mode 100644 .github/workflows/linux-build.yml create mode 100644 .github/workflows/main.yml delete mode 100644 .github/workflows/osx-build.yml diff --git a/.github/workflows/linux-build.yml b/.github/workflows/linux-build.yml deleted file mode 100644 index 1346961..0000000 --- a/.github/workflows/linux-build.yml +++ /dev/null @@ -1,45 +0,0 @@ -on: [push] -name: build-linux_amd64 -jobs: - build: - runs-on: ubuntu-20.04 - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - - name: build - uses: actions-rs/cargo@v1 - with: - command: build - - name: test - uses: actions-rs/cargo@v1 - with: - command: test - - name: lint - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - - name: e2e-test - run: | - sudo apt-get install zsh fish -y - echo "testing bash" - bash scripts/e2e-test.sh bash - echo "testing zsh" - zsh scripts/e2e-test.sh zsh - echo "testing fish" - fish scripts/e2e-test.fish fish - echo "testing run" - zsh scripts/e2e-test-run.sh - - name: build-release - if: startsWith(github.ref, 'refs/tags/') - run: | - cargo build --release - cp ./target/release/tome ./target/release/tome-linux_amd64 - - name: release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - files: ./target/release/tome-linux_amd64 - token: ${{ secrets.GITHUB_TOKEN }} - draft: true \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..9c08e4b --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,68 @@ +name: Build and Release +on: + # # Indicates I want to run this workflow on all branches, PR, and tags + push: + branches: ["*"] + tags: ["*"] + pull_request: + branches: ["master"] + +env: + BIN_NAME: "tome" + CRATE_NAME: tome + +jobs: + build: + name: ${{ matrix.platform.os_name }} with rust ${{ matrix.toolchain }} + runs-on: ${{ matrix.platform.os }} + strategy: + fail-fast: false + matrix: + platform: + - os_name: Linux-x86_64 + os: ubuntu-20.04 + target: x86_64-unknown-linux-musl + bin: tome + name: tome-linux-x86_64 + - os_name: Linux-aarch64 + os: ubuntu-20.04 + target: aarch64-unknown-linux-musl + bin: tome + name: tome-linux-aarch64 + - os_name: macOS-x86_64 + os: macOS-latest + target: x86_64-apple-darwin + bin: tome + name: tome-darwin-x86_64 + - os_name: macOS-aarch64 + os: macOS-latest + target: aarch64-apple-darwin + bin: tome + name: tome-darwin-aarch64 + # The action does not support running tests on aarch64-apple-darwin. + # https://github.com/houseabsolute/actions-rust-cross?tab=readme-ov-file#input-parameters + skip_tests: true + toolchain: + - stable + - beta + steps: + - uses: actions/checkout@v3 + - name: Install musl-tools on Linux + run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools + if: contains(matrix.platform.name, 'musl') + - name: Build binary + uses: houseabsolute/actions-rust-cross@v0.0.12 + with: + command: "build" + target: ${{ matrix.platform.target }} + toolchain: ${{ matrix.toolchain }} + args: "--locked --release" + strip: true + - name: Run tests + uses: houseabsolute/actions-rust-cross@v0 + with: + command: "test" + target: ${{ matrix.platform.target }} + toolchain: ${{ matrix.toolchain }} + args: "--locked --release" + if: ${{ !matrix.platform.skip_tests }} diff --git a/.github/workflows/osx-build.yml b/.github/workflows/osx-build.yml deleted file mode 100644 index 5133793..0000000 --- a/.github/workflows/osx-build.yml +++ /dev/null @@ -1,38 +0,0 @@ -on: [push] -name: build-osx -jobs: - build: - runs-on: macos-13 - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - - name: build - uses: actions-rs/cargo@v1 - with: - command: build - - name: test - uses: actions-rs/cargo@v1 - with: - command: test - - name: e2e-test - run: | - echo "testing bash" - bash scripts/e2e-test.sh bash - echo "testing zsh" - zsh scripts/e2e-test.sh zsh - echo "testing run" - zsh scripts/e2e-test-run.sh - - name: build-release - if: startsWith(github.ref, 'refs/tags/') - run: | - cargo build --release - cp ./target/release/tome ./target/release/tome-osx - - name: release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - with: - files: ./target/release/tome-osx - token: ${{ secrets.GITHUB_TOKEN }} - draft: true \ No newline at end of file diff --git a/example/file_example b/example/file_example index 515ddfd..b9b975a 100755 --- a/example/file_example +++ b/example/file_example @@ -1,17 +1,23 @@ -#!/usr/bin/env python +#!/usr/bin/env bash # SUMMARY: hey' # COMPLETE # START HELP # this is an example of a simple script written in python. # END HELP -import sys +#import sys # when attempting to complete a variable, # --complete will be passed, with the full argument set. # for example, # $ cb file_example foo a --complete # will pass all arguments (the "a" should be autocompleted.) -if len(sys.argv) > 1 and sys.argv[1] == "--complete": - sys.stdout.write("file autocomplete example") -else: - print("hello") +if [ "${1}" == "--complete" ]; then + echo -n "file autocomplete example" +else + echo "hello" +fi + +#if len(sys.argv) > 1 and sys.argv[1] == "--complete": +# sys.stdout.write("file autocomplete example") +#else: +# print("hello") diff --git a/example/test_files/file_example_no_completion b/example/test_files/file_example_no_completion index 78b470f..07d3c0e 100755 --- a/example/test_files/file_example_no_completion +++ b/example/test_files/file_example_no_completion @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # SUMMARY: hey' # START HELP # this is an example of a simple script written in python. diff --git a/src/lib_tests.rs b/src/lib_tests.rs index 864b5fd..98b864e 100644 --- a/src/lib_tests.rs +++ b/src/lib_tests.rs @@ -99,7 +99,7 @@ fn test_simple_script_completion() { } /// Unless the file has the completion annotation -/// do not invoked completion on it and return nothing +/// do not invoke completion on it and return nothing /// instead. #[test] fn test_simple_script_no_completion() {