From 59e04d5b1476843a7b6ad2cf85d1f3e1ff3f4b53 Mon Sep 17 00:00:00 2001 From: usagi-flow <2804556+usagi-flow@users.noreply.github.com> Date: Sat, 18 May 2024 20:35:31 +0200 Subject: [PATCH] Squashed commit of the following: commit 13654f976ac7be5b11dbb67dfc732974c65fc42d Author: usagi-flow <2804556+usagi-flow@users.noreply.github.com> Date: Sat May 18 00:03:44 2024 +0200 feat(ci): pr test/build workflow commit 80f3586f837728d05907acdc54ec8989f7ffe772 Author: usagi-flow <2804556+usagi-flow@users.noreply.github.com> Date: Sat May 18 00:03:44 2024 +0200 fix(ci): x86_64 macos build commit 26d458b82160bd0ea69ee72df6675e55915465b8 Author: usagi-flow <2804556+usagi-flow@users.noreply.github.com> Date: Thu Apr 25 20:44:51 2024 +0200 fix(ci): build and create a release when a release tag is pushed commit b89d1e3ea6ca345c2d80b3d186a8093d4a1d991f Author: usagi-flow <2804556+usagi-flow@users.noreply.github.com> Date: Thu Apr 25 20:44:51 2024 +0200 fix(ci): mac builds commit 4fee940bed8f50d4d43d926751a92e928c099c94 Author: usagi-flow <2804556+usagi-flow@users.noreply.github.com> Date: Thu Apr 25 20:44:51 2024 +0200 feat(commands): ci --- .forgejo/workflows/build.yaml | 111 +++++++++++++++++++++++++++ .github/workflows/evil-build-pr.yml | 62 +++++++++++++++ .github/workflows/evil-build-tag.yml | 109 ++++++++++++++++++++++++++ 3 files changed, 282 insertions(+) create mode 100644 .forgejo/workflows/build.yaml create mode 100644 .github/workflows/evil-build-pr.yml create mode 100644 .github/workflows/evil-build-tag.yml diff --git a/.forgejo/workflows/build.yaml b/.forgejo/workflows/build.yaml new file mode 100644 index 000000000..1cd9f11be --- /dev/null +++ b/.forgejo/workflows/build.yaml @@ -0,0 +1,111 @@ +# TODO: until the ci works better +#on: [push] +on: + workflow_dispatch: + +env: + CARGO_HOME: /workspace/nehu/helix/cargo-home + RUSTUP_HOME: /workspace/nehu/helix/rustup-home + #CROSS_CONTAINER_IN_CONTAINER: true + CROSS_CONTAINER_ENGINE: podman + HELIX_DEFAULT_RUNTIME: /usr/lib/helix/runtime + +jobs: + build: + strategy: + matrix: + target: + - id: x86_64-unknown-linux-gnu + name: amd64-linux + # TODO: doesn't work well yet + #- id: x86_64-apple-darwin + # name: amd64-macos + - id: aarch64-unknown-linux-gnu + name: arm64-linux + - id: aarch64-unknown-linux-musl + name: arm64-linux-musl + - id: arm-unknown-linux-musleabihf + name: armv6-linux-musl + max-parallel: 2 + runs-on: linux-x86_64 + container: + image: rust + #image: rust:alpine3.19 + steps: + # Required by 3rd-party actions + # `musl-dev` required to avoid the crti.o error (https://github.com/rust-lang/rust/issues/40174) + - run: "apt update && apt install -y podman git nodejs tree" + - run: mkdir -pv ~/.rustup ~/.cargo + - uses: "actions/checkout@v3" + - name: "Restore rustup cache" + id: "cache-rustup-restore" + uses: "actions/cache/restore@v4" + with: + path: | + rustup-home + key: "helix-rustup-${{ matrix.target.id }}" + - name: "Restore cargo cache" + id: "cache-cargo-restore" + uses: "actions/cache/restore@v4" + with: + path: | + cargo-home + key: "helix-cargo-${{ matrix.target.id }}" + - name: "Restore artifacts cache" + id: "cache-artifacts-restore" + uses: "actions/cache/restore@v4" + with: + path: | + target + key: "helix-artifacts-${{ matrix.target.id }}" + - name: "Install binstall" + uses: "https://github.com/cargo-bins/cargo-binstall@v1.6.5" + - name: "Install cross" + run: "cargo binstall -y cross" + #- name: "Install target: ${{ matrix.target.id }}" + # if: ${{ matrix.target.id == 'x86_64-apple-darwin' }} + # run: "rustup target add ${{ matrix.target.id }}" + - name: "Configure cross: ${{ matrix.target.id }}" + if: ${{ matrix.target.id == 'x86_64-apple-darwin' }} + run: | + echo "[target.${{ matrix.target.id }}]" >> Cross.toml + echo 'image = "ghcr.io/mrpixel1/x86_64-apple-darwin-cross:latest"' >> Cross.toml + - name: "Build" + run: $CARGO_HOME/bin/cross build --profile opt --target ${{ matrix.target.id }} + - name: "Save artifacts cache" + id: "cache-artifacts-save" + uses: "actions/cache/save@v4" + with: + path: | + target + key: "${{ steps.cache-artifacts-restore.outputs.cache-primary-key }}" + - name: "Save cargo cache" + if: "always()" + id: "cache-cargo-save" + uses: "actions/cache/save@v4" + with: + path: | + cargo-home + key: "${{ steps.cache-cargo-restore.outputs.cache-primary-key }}" + - name: "Save rustup cache" + if: "always()" + id: "cache-rustup-save" + uses: "actions/cache/save@v4" + with: + path: | + rustup-home + key: "${{ steps.cache-rustup-restore.outputs.cache-primary-key }}" + - name: "Prepare dist" + run: | + mkdir -pv dist/helix + mv -v target/${{ matrix.target.id }}/opt/hx dist/helix/ + rm -rf runtime/grammars/sources + mv -v runtime dist/helix/ + cd dist && tar -cvzf helix-${{ matrix.target.name }}.tar.gz helix + - name: "Upload artifacts" + # Temporary solution until https://code.forgejo.org/actions/upload-artifact works + #uses: "https://code.forgejo.org/forgejo/upload-artifact@v4" + uses: "https://code.forgejo.org/forgejo/upload-artifact@v3" + with: + name: helix-${{ matrix.target.name }} + path: dist/helix-${{ matrix.target.name }}.tar diff --git a/.github/workflows/evil-build-pr.yml b/.github/workflows/evil-build-pr.yml new file mode 100644 index 000000000..5bde94bef --- /dev/null +++ b/.github/workflows/evil-build-pr.yml @@ -0,0 +1,62 @@ +on: + pull_request: + workflow_dispatch: + +permissions: write-all + +env: + RUST_BACKTRACE: 1 + HELIX_LOG_LEVEL: info + HELIX_DEFAULT_RUNTIME: /opt/helix/runtime + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + build: + + strategy: + fail-fast: false + matrix: + target: + - id: x86_64-unknown-linux-gnu + name: amd64-linux + native: true + os: ubuntu-latest + + runs-on: ${{ matrix.target.os }} + + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install stable toolchain + uses: dtolnay/rust-toolchain@1.74 + with: + targets: ${{ matrix.target.id }} + + - uses: Swatinem/rust-cache@v2 + with: + shared-key: "build" + + - name: Test + run: cargo test + + - name: Build + run: cargo build --release + + - name: "Prepare dist" + run: | + mkdir -pv dist/helix + mv -v target/${{ matrix.target.id }}/opt/hx dist/helix/ + rm -rf runtime/grammars/sources + mv -v runtime dist/helix/ + cd dist && tar -cvzf helix-${{ matrix.target.name }}.tar.gz helix + + - name: "Upload artifacts" + uses: actions/upload-artifact@v4 + with: + name: helix-${{ matrix.target.name }} + path: dist/helix-${{ matrix.target.name }}.tar.gz diff --git a/.github/workflows/evil-build-tag.yml b/.github/workflows/evil-build-tag.yml new file mode 100644 index 000000000..71a9046a7 --- /dev/null +++ b/.github/workflows/evil-build-tag.yml @@ -0,0 +1,109 @@ +on: + push: + tags: + - "release-*" + +permissions: write-all + +env: + RUST_BACKTRACE: 1 + HELIX_LOG_LEVEL: info + HELIX_DEFAULT_RUNTIME: /opt/helix/runtime + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + build: + + strategy: + fail-fast: false + matrix: + target: + - id: x86_64-unknown-linux-gnu + name: amd64-linux + native: true + os: ubuntu-latest + - id: aarch64-unknown-linux-gnu + name: aarch64-linux + native: false + os: ubuntu-latest + - id: aarch64-unknown-linux-musl + name: aarch64-linux-musl + native: false + os: ubuntu-latest + - id: arm-unknown-linux-musleabihf + name: armv6-linux-musl + native: false + os: ubuntu-latest + - id: x86_64-apple-darwin + name: amd64-macos + native: true + os: macos-latest + - id: aarch64-apple-darwin + name: aarch64-macos + native: true + os: macos-latest + + runs-on: ${{ matrix.target.os }} + + steps: + - name: Checkout sources + uses: actions/checkout@v4 + + - name: Install stable toolchain + uses: dtolnay/rust-toolchain@1.74 + with: + targets: ${{ matrix.target.id }} + + - name: Install binstall + uses: "cargo-bins/cargo-binstall@v1.6.5" + if: ${{ !matrix.target.native}} + + - name: "Install cross" + run: "cargo binstall -y cross" + if: ${{ !matrix.target.native}} + + - uses: Swatinem/rust-cache@v2 + with: + shared-key: "build" + + - name: Build + run: | + rustup target add ${{ matrix.target.id }} + cargo build --target ${{ matrix.target.id }} --profile opt + if: ${{ matrix.target.native}} + + - name: Build (cross) + run: cross build --target ${{ matrix.target.id }} --profile opt + if: ${{ !matrix.target.native}} + + - name: "Prepare dist" + run: | + mkdir -pv dist/helix + mv -v target/${{ matrix.target.id }}/opt/hx dist/helix/ + rm -rf runtime/grammars/sources + mv -v runtime dist/helix/ + cd dist && tar -cvzf helix-${{ matrix.target.name }}.tar.gz helix + + - name: "Upload artifacts" + uses: actions/upload-artifact@v4 + with: + name: helix-${{ matrix.target.name }} + path: dist/helix-${{ matrix.target.name }}.tar.gz + + - name: Release suffix + id: release-suffix + run: echo "::set-output name=suffix::$(date +'%Y%m%d')" + + - name: Create release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: dist/* + file_glob: true + tag: ${{ github.ref }} + release_name: evil-helix-${{steps.release-suffix.outputs.suffix}} + overwrite: true