Skip to content

Commit

Permalink
ruff.yml (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
hemnstill authored Jul 26, 2023
1 parent 096bac3 commit f43c358
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: ruff
# version_tests: skip_readme

on: [pull_request, workflow_dispatch]

jobs:
alpine-musl:
if: ${{ vars.CURRENT_TOOL == github.workflow }}
uses: ./.github/workflows/build-alpine.yml
with:
workflow: ${{ github.workflow }}

alpine-mingw:
if: ${{ vars.CURRENT_TOOL == github.workflow }}
uses: ./.github/workflows/build-alpine.yml
with:
workflow: ${{ github.workflow }}
toolset: mingw

test-alpine:
needs: alpine-musl
uses: ./.github/workflows/test-alpine.yml
with:
workflow: ${{ github.workflow }}
artifact: build-musl

test-ubuntu:
needs: alpine-musl
uses: ./.github/workflows/test-ubuntu.yml
with:
workflow: ${{ github.workflow }}
artifact: build-musl

test-windows:
needs: alpine-mingw
uses: ./.github/workflows/test-windows.yml
with:
workflow: ${{ github.workflow }}
artifact: build-mingw

release:
needs: [test-alpine,
test-ubuntu,
test-windows]
uses: ./.github/workflows/release.yml
with:
workflow: ${{ github.workflow }}
tool_version: '0.0.280'
prepare_body: |
bsdtar -Oxf ./build-musl/build-musl.tar.gz build-musl.md >> body.md
bsdtar -Oxf ./build-mingw/build-mingw.tar.gz build-mingw.md >> body.md
artifacts: ./build-musl/build-musl.tar.gz,./build-mingw/build-mingw.tar.gz
secrets:
token: ${{ secrets.GITHUB_TOKEN }}
52 changes: 52 additions & 0 deletions ruff/build_mingw.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
dp0="$(realpath "$(dirname "$0")")"
set -e

echo "::group::install deps"

apk update
apk add --no-cache alpine-sdk musl-dev gcc curl wget rustup pkgconfig openssl-dev mingw-w64-gcc

rustup-init -y
. "$HOME/.cargo/env"

echo "::endgroup::"

tool_name="ruff"
tool_version="0.0.280"
self_name="build-$tool_name-$tool_version"
self_toolset_name="build-mingw"
release_version_dirpath="$dp0/release/$self_name"

mkdir -p "$release_version_dirpath" && cd "$dp0/release"

download_url="https://github.com/astral-sh/ruff/archive/refs/tags/v$tool_version.tar.gz"
echo "::group::prepare sources $download_url"

"$dp0/../.tools/download_bsdtar.sh"
bsdtar="$dp0/release/bsdtar"

wget "$download_url" -O "tool-$tool_version.tar.gz"
"$bsdtar" -xf "tool-$tool_version.tar.gz" && cd "$tool_name-$tool_version"

cargo fetch
rustup target add x86_64-pc-windows-gnu
cargo build --target x86_64-pc-windows-gnu --release

cp -f "./target/x86_64-pc-windows-gnu/release/$tool_name.exe" "$release_version_dirpath/"

echo "::endgroup::"

cd "$release_version_dirpath"

strip "$tool_name.exe"

{ printf '### %s
SHA-256: %s
' "$self_toolset_name.tar.gz" "$(sha256sum $tool_name.exe)"
} > "$self_toolset_name.md"

cat "$self_toolset_name.md"

tar -czvf "../$self_toolset_name.tar.gz" .
52 changes: 52 additions & 0 deletions ruff/build_musl.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
dp0="$(realpath "$(dirname "$0")")"
set -e

echo "::group::install deps"

apk update
apk add --no-cache alpine-sdk musl-dev gcc curl wget rustup pkgconfig openssl-dev

rustup-init -y
. "$HOME/.cargo/env"

echo "::endgroup::"

tool_name="ruff"
tool_version="0.0.280"
self_name="build-$tool_name-$tool_version"
self_toolset_name="build-musl"
release_version_dirpath="$dp0/release/$self_name"

mkdir -p "$release_version_dirpath" && cd "$dp0/release"

download_url="https://github.com/astral-sh/ruff/archive/refs/tags/v$tool_version.tar.gz"
echo "::group::prepare sources $download_url"

"$dp0/../.tools/download_bsdtar.sh"
bsdtar="$dp0/release/bsdtar"

wget "$download_url" -O "tool-$tool_version.tar.gz"
"$bsdtar" -xf "tool-$tool_version.tar.gz" && cd "$tool_name-$tool_version"

cargo build --target x86_64-unknown-linux-musl --release

cp -f "./target/x86_64-unknown-linux-musl/release/$tool_name" "$release_version_dirpath/"

echo "::endgroup::"

cd "$release_version_dirpath"
strip "$tool_name"
chmod +x "$tool_name"

{ printf '%s
### %s
SHA-256: %s
' "$("./$tool_name" --version)" "$self_toolset_name.tar.gz" "$(sha256sum $tool_name)"
} > "$self_toolset_name.md"

cat "$self_toolset_name.md"

tar -czvf "../$self_toolset_name.tar.gz" .
8 changes: 8 additions & 0 deletions ruff/test_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

testVersion() {
assertEquals "ruff 0.0.280" "$(../bin/ruff --version)"
}

# Load and run shUnit2.
source "../.tests/shunit2/shunit2"
8 changes: 8 additions & 0 deletions ruff/test_windows.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

testVersion() {
assertEquals "ruff 0.0.280" "$(../bin/ruff.exe --version)"
}

# Load and run shUnit2.
source "../.tests/shunit2/shunit2"

0 comments on commit f43c358

Please sign in to comment.