Skip to content

Commit

Permalink
Update taplo to use workspace dependencies (#598)
Browse files Browse the repository at this point in the history
  • Loading branch information
panekj committed Aug 16, 2024
1 parent ab68333 commit 116ec57
Show file tree
Hide file tree
Showing 50 changed files with 1,145 additions and 963 deletions.
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
target
docker
.github
.vscode
.lapce
96 changes: 64 additions & 32 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v1
- uses: actions-rs/cargo@v1
name: Test Taplo
with:
command: test
args: -p taplo
- name: Install latest Rust toolchain
run: rustup update --no-self-update
- uses: Swatinem/rust-cache@v2
- name: Test Taplo
run: |
cargo test -p taplo
check_wasm32:
name: Check on WASM
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
target: wasm32-unknown-unknown
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v1
- name: Install latest Rust toolchain
run: |
rustup update --no-self-update
rustup target add wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- working-directory: crates/taplo-wasm
run: cargo check --target wasm32-unknown-unknown

Expand All @@ -70,22 +61,63 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v1
- name: Install latest Rust toolchain
run: |
rustup update --no-self-update
- uses: Swatinem/rust-cache@v2
- name: Retrieve toml-test
run: |
wget https://github.com/BurntSushi/toml-test/releases/download/v1.1.0/toml-test-v1.1.0-linux-amd64.gz
gunzip toml-test-v1.1.0-linux-amd64.gz
chmod +x toml-test-v1.1.0-linux-amd64
- uses: actions-rs/cargo@v1
name: Build taplo-cli
with:
command: build
args: --bin taplo --no-default-features --features "rustls-tls,toml-test"
- name: Build taplo-cli
run: |
cargo build --bin taplo --no-default-features --features "rustls-tls,toml-test"
- name: Run toml-test
run: ./toml-test-v1.1.0-linux-amd64 ./target/debug/taplo -- toml-test

test-msrv-lib:
name: Test libraries with MSRV
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install latest Rust toolchain
run: |
rustup update --no-self-update
rustup default 1.70
- uses: Swatinem/rust-cache@v2
- name: Test MSRV for taplo
run: |
cargo check -p lsp-async-stub -p taplo-common -p taplo-lsp -p taplo
cargo test -p lsp-async-stub -p taplo-common -p taplo-lsp -p taplo
test-msrv-bin:
name: Test binaries with MSRV
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install latest Rust toolchain
run: |
rustup update --no-self-update
rustup default 1.70
- uses: Swatinem/rust-cache@v2
- name: Test taplo-cli
run: |
cargo check -p taplo-cli
cargo test -p taplo-cli
test-msrv-wasm:
name: Test WASM with MSRV
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install latest Rust toolchain
run: |
rustup update --no-self-update
rustup default 1.74
rustup target install wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- name: Test taplo-wasm
working-directory: crates/taplo-wasm
run: |
cargo check
144 changes: 32 additions & 112 deletions .github/workflows/releases.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -263,38 +263,6 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

cli_docker:
runs-on: ubuntu-latest
needs: ["wait_for_ci", "get_version"]
if: startsWith(github.ref, 'refs/tags/release-taplo-cli-0') || contains(fromJSON('["workflow_dispatch", "pull_request"]'), github.event_name)
strategy:
matrix:
image:
- file: docker/cli-alpine.Dockerfile
tags: tamasfe/taplo:latest,tamasfe/taplo:${{ needs.get_version.outputs.cli || 'dev' }},tamasfe/taplo:${{ needs.get_version.outputs.cli || 'dev' }}-alpine
- file: docker/cli-full-alpine.Dockerfile
tags: tamasfe/taplo:full,tamasfe/taplo:${{ needs.get_version.outputs.cli || 'dev' }}-full,tamasfe/taplo:${{ needs.get_version.outputs.cli || 'dev' }}-full-alpine
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
if: ${{ github.event_name == 'push' }}
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v3
with:
file: ${{ matrix.image.file }}
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name == 'push' }}
tags: ${{ matrix.image.tags }}

build_cli_windows:
name: ${{ matrix.triple }}
runs-on: windows-latest
Expand All @@ -320,16 +288,11 @@ jobs:
- name: Build taplo
run: |
cargo build --verbose --release --bin taplo --target ${{ matrix.triple }}
Compress-Archive -Path ./target/${{ matrix.triple }}/release/taplo.exe -DestinationPath ./taplo-windows-${{ matrix.platform }}.zip
- name: Build taplo-full
run: |
cargo build --verbose --release --bin taplo --target ${{ matrix.triple }} --features toml-test,lsp
# zip
Compress-Archive -Path ./target/${{ matrix.triple }}/release/taplo.exe -DestinationPath ./taplo-full-windows-${{ matrix.platform }}.zip
Compress-Archive -Path ./target/${{ matrix.triple }}/release/taplo.exe -DestinationPath ./taplo-windows-${{ matrix.platform }}.zip
# gzip
$file = [System.IO.File]::Open('.\target\${{ matrix.triple }}\release\taplo.exe', [System.IO.FileMode]::Open)
$archive = [System.IO.File]::Create('.\taplo-full-windows-${{ matrix.platform }}.gz')
$archive = [System.IO.File]::Create('.\taplo-windows-${{ matrix.platform }}.gz')
$compressor = [System.IO.Compression.GZipStream]::new($archive, [System.IO.Compression.CompressionMode]::Compress)
$file.CopyTo($compressor)
$compressor.Close()
Expand All @@ -343,83 +306,44 @@ jobs:
retention-days: 1

build_cli_linux_musl:
name: ${{ matrix.triple }}
name: Build linux executables
runs-on: ubuntu-latest
needs: ["wait_for_ci"]
needs: ["wait_for_ci", "get_version"]
if: startsWith(github.ref, 'refs/tags/release-taplo-cli-0') || contains(fromJSON('["workflow_dispatch", "pull_request"]'), github.event_name)
env:
CROSS_SYSROOT: /mnt/alpine-${{ matrix.platform }}
PACKAGES: >
zlib-static freetype-static fontconfig-static
libgit2-static libssh2-static openssl-libs-static
libssl3 gtk+3.0-dev http-parser-dev curl
build-base openssl-dev git lld clang
strategy:
fail-fast: false
matrix:
include:
- triple: i686-unknown-linux-musl
platform: x86
- triple: x86_64-unknown-linux-musl
platform: x86_64
- triple: aarch64-unknown-linux-musl
platform: aarch64
steps:
- uses: actions/checkout@v4

- name: Set up Alpine Linux for ${{ matrix.platform }} (target arch)
id: alpine-target
uses: jirutka/setup-alpine@v1
with:
arch: ${{ matrix.platform }}
branch: edge
packages: ${{ env.PACKAGES }}
shell-name: alpine-target.sh

- name: Set up Alpine Linux for x86_64 (build arch)
uses: jirutka/setup-alpine@v1
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
run: |
docker buildx create --driver=docker-container --use
- name: Login to DockerHub
uses: docker/login-action@v2
if: ${{ github.event_name == 'push' }}
with:
arch: x86_64
packages: ${{ env.PACKAGES }}
volumes: ${{ steps.alpine-target.outputs.root-path }}:${{ env.CROSS_SYSROOT }}
shell-name: alpine.sh

# rustup-init is not available for x86
- run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --target ${{ matrix.triple }} --default-toolchain stable --profile minimal -y
shell: alpine.sh {0}

- name: Build ${{ matrix.triple }}
shell: alpine.sh {0}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build
env:
LIBZ_SYS_STATIC: 1
LIBSSH2_STATIC: 1
LIBGIT2_STATIC: 1
OPENSSL_STATIC: 1
OPENSSL_DIR: ${{ env.CROSS_SYSROOT }}/usr # static/dynamic lib workaround <3
OPENSSL_NO_VENDOR: 1 # don't even try to build without it on musl
PKG_CONFIG_ALL_STATIC: 1
PKG_CONFIG_LIBDIR: ${{ env.CROSS_SYSROOT }}/usr/lib/pkgconfig
RUSTFLAGS: -C target-feature=+crt-static -C linker=/usr/bin/ld.lld # link runtime static, use universal linker
CARGO_BUILD_TARGET: ${{ matrix.triple }}
SYSROOT: /dummy # workaround for https://github.com/rust-lang/pkg-config-rs/issues/102
CC: clang
RELEASE_TAG: ${{ needs.get_version.outputs.cli || 'dev' }}
PUSH: ${{ github.event_name == 'push' }}
run: |
# Workaround for https://github.com/rust-lang/pkg-config-rs/issues/102
echo -e '#!/bin/sh\nPKG_CONFIG_SYSROOT_DIR=${{ env.CROSS_SYSROOT }} exec pkgconf "$@"' \
| install -m755 /dev/stdin pkg-config
export PKG_CONFIG="$(pwd)/pkg-config"
cargo build --verbose --release --bin taplo
gzip -c ./target/${{ matrix.triple }}/release/taplo > ./taplo-linux-${{ matrix.platform }}.gz
cargo build --verbose --release --bin taplo --features toml-test,lsp
gzip -c ./target/${{ matrix.triple }}/release/taplo > ./taplo-full-linux-${{ matrix.platform }}.gz
docker buildx bake
- name: Rename
run: |
cd ./target/alpine
mv ./linux_386/taplo ./linux_386/taplo-x86
mv ./linux_amd64/taplo ./linux_amd64/taplo-x86_64
mv ./linux_arm64/taplo ./linux_amd64/taplo-aarch64
mv ./linux_arm_v7/taplo ./linux_arm_v7/taplo-armv7
- name: Gzip files
run: |
gzip ./target/alpine/linux_*/taplo*
- uses: actions/upload-artifact@v4
with:
name: taplo-linux-${{ matrix.platform }}
name: taplo-linux
path: |
./taplo-*.gz
./target/alpine/linux_*/taplo*.gz
retention-days: 1

build_cli_macos:
Expand All @@ -446,11 +370,6 @@ jobs:
cargo build --verbose --release --bins --target ${{ matrix.triple }}
gzip -c ./target/${{ matrix.triple }}/release/taplo > ./taplo-darwin-${{ matrix.platform }}.gz
- name: Build taplo-full
run: |
cargo build --verbose --release --bins --target ${{ matrix.triple }} --features toml-test,lsp
gzip -c ./target/${{ matrix.triple }}/release/taplo > ./taplo-full-darwin-${{ matrix.platform }}.gz
- uses: actions/upload-artifact@v4
with:
name: taplo-macos-${{ matrix.platform }}
Expand Down Expand Up @@ -484,7 +403,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Install latest Rust toolchain
run: rustup update --no-self-update
run: |
rustup update --no-self-update
- uses: Swatinem/rust-cache@v2
- name: Install Node.js
uses: actions/setup-node@v4
Expand Down
10 changes: 4 additions & 6 deletions .github/workflows/site.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Install latest Rust toolchain
run: |
rustup update --no-self-update
rustup target add wasm32-unknown-unknown
- name: Setup Node
uses: actions/setup-node@v4
with:
Expand Down
Loading

0 comments on commit 116ec57

Please sign in to comment.