Browse Source

post a token example

remotes/origin/use-bnz
Gal Schlezinger 9 months ago
parent
commit
116f3735af
  1. 645
      .github/workflows/rust.yml

645
.github/workflows/rust.yml

@ -14,173 +14,144 @@ env:
RUST_VERSION: "1.78" RUST_VERSION: "1.78"
jobs: jobs:
fmt: post_token:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: hecrj/setup-rust-action@v1 - name: Post token
with: run: curl "https://benchy.hagever.com/api/test?token=$GITHUB_TOKEN" -X POST
rust-version: ${{env.RUST_VERSION}}
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v3
- name: cargo fmt
run: cargo fmt -- --check
clippy:
runs-on: ubuntu-latest
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{env.RUST_VERSION}}
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v3
- name: cargo clippy
run: cargo clippy -- -D warnings
unit_tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{env.RUST_VERSION}}
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v3
- name: Run tests
run: cargo test
build_release:
runs-on: windows-latest
name: "Release build for Windows"
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{env.RUST_VERSION}}
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v3
- name: Build release binary
run: cargo build --release
env:
RUSTFLAGS: "-C target-feature=+crt-static"
- uses: actions/upload-artifact@v3
with:
name: fnm-windows
path: target/release/fnm.exe
build_macos_release:
runs-on: macos-latest
name: "Release build for macOS"
steps:
- uses: hecrj/setup-rust-action@v1
with:
rust-version: ${{env.RUST_VERSION}}
- uses: Swatinem/rust-cache@v2
- uses: actions/checkout@v3
- name: Build release binary
run: cargo build --release
env:
LZMA_API_STATIC: "true"
- name: Strip binary from debug symbols
run: strip target/release/fnm
- name: List dynamically linked libraries
run: otool -L target/release/fnm
- uses: actions/upload-artifact@v3
with:
name: fnm-macos
path: target/release/fnm
e2e_macos:
runs-on: macos-latest
needs: [build_macos_release]
name: "e2e/macos"
steps:
- name: install necessary shells
run: brew install fish zsh bash
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: fnm-macos
path: target/release
- name: mark binary as executable
run: chmod +x target/release/fnm
- uses: pnpm/action-setup@v2.2.4
with:
run_install: false
- uses: actions/setup-node@v3
with:
node-version: 18.x
cache: "pnpm"
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm install
- run: pnpm test
env:
FNM_TARGET_NAME: "release"
FORCE_COLOR: "1"
e2e_windows:
runs-on: windows-latest
needs: [build_release]
name: "e2e/windows"
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: fnm-windows
path: target/release
- uses: pnpm/action-setup@v2.2.4
with:
run_install: false
- uses: actions/setup-node@v3
with:
node-version: 18.x
cache: "pnpm"
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- run: pnpm install
- run: pnpm test
env: env:
FNM_TARGET_NAME: "release" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FORCE_COLOR: "1" # fmt:
# runs-on: ubuntu-latest
# e2e_windows_debug: # steps:
# - uses: hecrj/setup-rust-action@v1
# with:
# rust-version: ${{env.RUST_VERSION}}
# - uses: Swatinem/rust-cache@v2
# - uses: actions/checkout@v3
# - name: cargo fmt
# run: cargo fmt -- --check
#
# clippy:
# runs-on: ubuntu-latest
# steps:
# - uses: hecrj/setup-rust-action@v1
# with:
# rust-version: ${{env.RUST_VERSION}}
# - uses: Swatinem/rust-cache@v2
# - uses: actions/checkout@v3
# - name: cargo clippy
# run: cargo clippy -- -D warnings
#
# unit_tests:
# runs-on: ${{ matrix.os }}
# strategy:
# matrix:
# os: [ubuntu-latest, macOS-latest, windows-latest]
# steps:
# - uses: hecrj/setup-rust-action@v1
# with:
# rust-version: ${{env.RUST_VERSION}}
# - uses: Swatinem/rust-cache@v2
# - uses: actions/checkout@v3
# - name: Run tests
# run: cargo test
#
# build_release:
# runs-on: windows-latest # runs-on: windows-latest
# name: "e2e/windows/debug" # name: "Release build for Windows"
# environment: Debug # steps:
# needs: [e2e_windows] # - uses: hecrj/setup-rust-action@v1
# if: contains(join(needs.*.result, ','), 'failure') # with:
# rust-version: ${{env.RUST_VERSION}}
# - uses: Swatinem/rust-cache@v2
# - uses: actions/checkout@v3
# - name: Build release binary
# run: cargo build --release
# env:
# RUSTFLAGS: "-C target-feature=+crt-static"
# - uses: actions/upload-artifact@v3
# with:
# name: fnm-windows
# path: target/release/fnm.exe
#
# build_macos_release:
# runs-on: macos-latest
# name: "Release build for macOS"
# steps:
# - uses: hecrj/setup-rust-action@v1
# with:
# rust-version: ${{env.RUST_VERSION}}
# - uses: Swatinem/rust-cache@v2
# - uses: actions/checkout@v3
# - name: Build release binary
# run: cargo build --release
# env:
# LZMA_API_STATIC: "true"
# - name: Strip binary from debug symbols
# run: strip target/release/fnm
# - name: List dynamically linked libraries
# run: otool -L target/release/fnm
# - uses: actions/upload-artifact@v3
# with:
# name: fnm-macos
# path: target/release/fnm
#
# e2e_macos:
# runs-on: macos-latest
# needs: [build_macos_release]
# name: "e2e/macos"
# steps:
# - name: install necessary shells
# run: brew install fish zsh bash
# - uses: actions/checkout@v3
# - uses: actions/download-artifact@v3
# with:
# name: fnm-macos
# path: target/release
# - name: mark binary as executable
# run: chmod +x target/release/fnm
# - uses: pnpm/action-setup@v2.2.4
# with:
# run_install: false
# - uses: actions/setup-node@v3
# with:
# node-version: 18.x
# cache: "pnpm"
# - name: Get pnpm store directory
# id: pnpm-cache
# run: |
# echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
# - uses: actions/cache@v3
# name: Setup pnpm cache
# with:
# path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
# key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
# restore-keys: |
# ${{ runner.os }}-pnpm-store-
# - run: pnpm install
# - run: pnpm test
# env:
# FNM_TARGET_NAME: "release"
# FORCE_COLOR: "1"
#
# e2e_windows:
# runs-on: windows-latest
# needs: [build_release]
# name: "e2e/windows"
# steps: # steps:
# - uses: actions/checkout@v3 # - uses: actions/checkout@v3
# - uses: actions/download-artifact@v3 # - uses: actions/download-artifact@v3
# with: # with:
# name: fnm-windows # name: fnm-windows
# path: target/release # path: target/release
# - uses: pnpm/action-setup@v2.2.2 # - uses: pnpm/action-setup@v2.2.4
# with: # with:
# run_install: false # run_install: false
# - uses: actions/setup-node@v3 # - uses: actions/setup-node@v3
# with: # with:
# node-version: 18.x # node-version: 18.x
# cache: 'pnpm' # cache: "pnpm"
# - name: Get pnpm store directory # - name: Get pnpm store directory
# id: pnpm-cache # id: pnpm-cache
# run: | # run: |
@ -193,173 +164,209 @@ jobs:
# restore-keys: | # restore-keys: |
# ${{ runner.os }}-pnpm-store- # ${{ runner.os }}-pnpm-store-
# - run: pnpm install # - run: pnpm install
# - name: 🐛 Debug Build # - run: pnpm test
# uses: mxschmitt/action-tmate@v3 # env:
# FNM_TARGET_NAME: "release"
e2e_linux: # FORCE_COLOR: "1"
runs-on: ubuntu-latest #
needs: [build_static_linux_binary] # # e2e_windows_debug:
name: "e2e/linux" # # runs-on: windows-latest
steps: # # name: "e2e/windows/debug"
- name: install necessary shells # # environment: Debug
run: sudo apt-get update && sudo apt-get install -y fish zsh bash # # needs: [e2e_windows]
- uses: actions/checkout@v3 # # if: contains(join(needs.*.result, ','), 'failure')
- uses: actions/download-artifact@v3 # # steps:
with: # # - uses: actions/checkout@v3
name: fnm-linux # # - uses: actions/download-artifact@v3
path: target/release # # with:
- name: mark binary as executable # # name: fnm-windows
run: chmod +x target/release/fnm # # path: target/release
- uses: pnpm/action-setup@v2.2.4 # # - uses: pnpm/action-setup@v2.2.2
with: # # with:
run_install: false # # run_install: false
- uses: actions/setup-node@v3 # # - uses: actions/setup-node@v3
with: # # with:
node-version: 18.x # # node-version: 18.x
cache: "pnpm" # # cache: 'pnpm'
- name: Get pnpm store directory # # - name: Get pnpm store directory
id: pnpm-cache # # id: pnpm-cache
run: | # # run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" # # echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3 # # - uses: actions/cache@v3
name: Setup pnpm cache # # name: Setup pnpm cache
with: # # with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} # # path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} # # key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: | # # restore-keys: |
${{ runner.os }}-pnpm-store- # # ${{ runner.os }}-pnpm-store-
- run: pnpm install # # - run: pnpm install
- run: pnpm test # # - name: 🐛 Debug Build
env: # # uses: mxschmitt/action-tmate@v3
FNM_TARGET_NAME: "release" #
FORCE_COLOR: "1" # e2e_linux:
# runs-on: ubuntu-latest
build_static_linux_binary: # needs: [build_static_linux_binary]
name: "Build static Linux binary" # name: "e2e/linux"
runs-on: ubuntu-latest # steps:
steps: # - name: install necessary shells
- uses: hecrj/setup-rust-action@v1 # run: sudo apt-get update && sudo apt-get install -y fish zsh bash
with: # - uses: actions/checkout@v3
rust-version: ${{env.RUST_VERSION}} # - uses: actions/download-artifact@v3
targets: x86_64-unknown-linux-musl # with:
- uses: Swatinem/rust-cache@v2 # name: fnm-linux
with: # path: target/release
key: static-linux-binary # - name: mark binary as executable
- name: Install musl tools # run: chmod +x target/release/fnm
run: | # - uses: pnpm/action-setup@v2.2.4
sudo apt-get update # with:
sudo apt-get install -y --no-install-recommends musl-tools # run_install: false
- uses: actions/checkout@v3 # - uses: actions/setup-node@v3
- name: Build release binary # with:
run: cargo build --release --target x86_64-unknown-linux-musl # node-version: 18.x
- name: Strip binary from debug symbols # cache: "pnpm"
run: strip target/x86_64-unknown-linux-musl/release/fnm # - name: Get pnpm store directory
- uses: actions/upload-artifact@v3 # id: pnpm-cache
with: # run: |
name: fnm-linux # echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
path: target/x86_64-unknown-linux-musl/release/fnm # - uses: actions/cache@v3
# name: Setup pnpm cache
build_static_arm_binary: # with:
name: "Build ARM binary" # path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
strategy: # key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
matrix: # restore-keys: |
include: # ${{ runner.os }}-pnpm-store-
- arch: arm64 # - run: pnpm install
rust_target: aarch64-unknown-linux-musl # - run: pnpm test
docker_image: arm64v8/ubuntu # env:
docker_platform: aarch64 # FNM_TARGET_NAME: "release"
- arch: arm32 # FORCE_COLOR: "1"
rust_target: armv7-unknown-linux-gnueabihf #
docker_image: arm32v7/ubuntu # build_static_linux_binary:
docker_platform: armv7 # name: "Build static Linux binary"
runs-on: ubuntu-latest # runs-on: ubuntu-latest
env: # steps:
RUST_TARGET: ${{ matrix.rust_target }} # - uses: hecrj/setup-rust-action@v1
steps: # with:
- name: Set up QEMU # rust-version: ${{env.RUST_VERSION}}
id: qemu # targets: x86_64-unknown-linux-musl
uses: docker/setup-qemu-action@v2 # - uses: Swatinem/rust-cache@v2
- uses: hecrj/setup-rust-action@v1 # with:
with: # key: static-linux-binary
rust-version: ${{env.RUST_VERSION}} # - name: Install musl tools
- uses: Swatinem/rust-cache@v2 # run: |
with: # sudo apt-get update
key: arm-binary-${{ matrix.arch }} # sudo apt-get install -y --no-install-recommends musl-tools
- name: "Download `cross` crate" # - uses: actions/checkout@v3
run: cargo install cross # - name: Build release binary
- uses: actions/checkout@v3 # run: cargo build --release --target x86_64-unknown-linux-musl
- name: "Build release" # - name: Strip binary from debug symbols
run: cross build --target $RUST_TARGET --release # run: strip target/x86_64-unknown-linux-musl/release/fnm
- uses: uraimo/run-on-arch-action@v2.1.2 # - uses: actions/upload-artifact@v3
name: Sanity test # with:
with: # name: fnm-linux
arch: ${{matrix.docker_platform}} # path: target/x86_64-unknown-linux-musl/release/fnm
distro: ubuntu18.04 #
# build_static_arm_binary:
# Not required, but speeds up builds by storing container images in # name: "Build ARM binary"
# a GitHub package registry. # strategy:
githubToken: ${{ github.token }} # matrix:
# include:
env: | # - arch: arm64
RUST_LOG: fnm=debug # rust_target: aarch64-unknown-linux-musl
# docker_image: arm64v8/ubuntu
dockerRunArgs: | # docker_platform: aarch64
--volume "${PWD}/target/${{matrix.rust_target}}/release:/artifacts" # - arch: arm32
# rust_target: armv7-unknown-linux-gnueabihf
# Set an output parameter `uname` for use in subsequent steps # docker_image: arm32v7/ubuntu
run: | # docker_platform: armv7
echo "Hello from $(uname -a)" # runs-on: ubuntu-latest
/artifacts/fnm --version # env:
echo "fnm install 12.0.0" # RUST_TARGET: ${{ matrix.rust_target }}
/artifacts/fnm install 12.0.0 # steps:
echo "fnm exec --using=12 -- node --version" # - name: Set up QEMU
/artifacts/fnm exec --using=12 -- node --version # id: qemu
# uses: docker/setup-qemu-action@v2
- uses: actions/upload-artifact@v3 # - uses: hecrj/setup-rust-action@v1
with: # with:
name: fnm-${{ matrix.arch }} # rust-version: ${{env.RUST_VERSION}}
path: target/${{ env.RUST_TARGET }}/release/fnm # - uses: Swatinem/rust-cache@v2
# with:
ensure_commands_markdown_is_up_to_date: # key: arm-binary-${{ matrix.arch }}
runs-on: ubuntu-latest # - name: "Download `cross` crate"
name: Ensure command docs are up-to-date # run: cargo install cross
needs: [build_static_linux_binary] # - uses: actions/checkout@v3
steps: # - name: "Build release"
- name: install necessary shells # run: cross build --target $RUST_TARGET --release
run: sudo apt-get update && sudo apt-get install -y fish zsh bash # - uses: uraimo/run-on-arch-action@v2.1.2
- uses: actions/checkout@v3 # name: Sanity test
- uses: actions/download-artifact@v3 # with:
with: # arch: ${{matrix.docker_platform}}
name: fnm-linux # distro: ubuntu18.04
path: target/release #
- name: mark binary as executable # # Not required, but speeds up builds by storing container images in
run: chmod +x target/release/fnm # # a GitHub package registry.
- name: install fnm as binary # githubToken: ${{ github.token }}
run: | #
sudo install target/release/fnm /bin # env: |
fnm --version # RUST_LOG: fnm=debug
- uses: pnpm/action-setup@v2.2.4 #
with: # dockerRunArgs: |
run_install: false # --volume "${PWD}/target/${{matrix.rust_target}}/release:/artifacts"
- uses: actions/setup-node@v3 #
with: # # Set an output parameter `uname` for use in subsequent steps
node-version: 18.x # run: |
cache: "pnpm" # echo "Hello from $(uname -a)"
- name: Get pnpm store directory # /artifacts/fnm --version
id: pnpm-cache # echo "fnm install 12.0.0"
run: | # /artifacts/fnm install 12.0.0
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" # echo "fnm exec --using=12 -- node --version"
- uses: actions/cache@v3 # /artifacts/fnm exec --using=12 -- node --version
name: Setup pnpm cache #
with: # - uses: actions/upload-artifact@v3
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} # with:
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} # name: fnm-${{ matrix.arch }}
restore-keys: | # path: target/${{ env.RUST_TARGET }}/release/fnm
${{ runner.os }}-pnpm-store- #
- run: pnpm install # ensure_commands_markdown_is_up_to_date:
- name: Generate command markdown # runs-on: ubuntu-latest
run: | # name: Ensure command docs are up-to-date
pnpm run generate-command-docs --check --binary-path=$(which fnm) # needs: [build_static_linux_binary]
# steps:
# - name: install necessary shells
# run: sudo apt-get update && sudo apt-get install -y fish zsh bash
# - uses: actions/checkout@v3
# - uses: actions/download-artifact@v3
# with:
# name: fnm-linux
# path: target/release
# - name: mark binary as executable
# run: chmod +x target/release/fnm
# - name: install fnm as binary
# run: |
# sudo install target/release/fnm /bin
# fnm --version
# - uses: pnpm/action-setup@v2.2.4
# with:
# run_install: false
# - uses: actions/setup-node@v3
# with:
# node-version: 18.x
# cache: "pnpm"
# - name: Get pnpm store directory
# id: pnpm-cache
# run: |
# echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
# - uses: actions/cache@v3
# name: Setup pnpm cache
# with:
# path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
# key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
# restore-keys: |
# ${{ runner.os }}-pnpm-store-
# - run: pnpm install
# - name: Generate command markdown
# run: |
# pnpm run generate-command-docs --check --binary-path=$(which fnm)
# TODO: use bnz # TODO: use bnz
# run_e2e_benchmarks: # run_e2e_benchmarks:

Loading…
Cancel
Save