Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: cargo xtask #562

Merged
merged 20 commits into from Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
aa87a45
feat: migrate build.rs to cargo xtask dist
EverlastingBugstopper May 21, 2021
86fbd19
feat: adds --verbose flag
EverlastingBugstopper May 24, 2021
6642d98
feat(xtask): adds xtask dist and xtask prep
EverlastingBugstopper May 26, 2021
5379379
feat(xtask): adds xtask lint and xtask test
EverlastingBugstopper May 26, 2021
8f1eec6
removes deps
EverlastingBugstopper May 26, 2021
781f894
chore: replaces action steps with xtask steps
EverlastingBugstopper May 28, 2021
481bb29
chore: updates release_checklist.md
EverlastingBugstopper May 28, 2021
a729da9
chore: adds contributing.md to xtask prep
EverlastingBugstopper May 28, 2021
8a8202e
docs: extend contribution guide (#594)
EverlastingBugstopper Jun 10, 2021
8c4718f
chore: move xtask to root directory
EverlastingBugstopper Jun 10, 2021
8ecaf18
chore: update docs
EverlastingBugstopper Jun 10, 2021
7901c2a
fix: xtask path
EverlastingBugstopper Jun 10, 2021
ea49ffb
chore: extend xtask readme
EverlastingBugstopper Jun 10, 2021
4147451
fix: attempt xtask fix for windows
EverlastingBugstopper Jun 10, 2021
70373db
fix: actually run tests
EverlastingBugstopper Jun 10, 2021
2e781df
fix(ci): dont use env in matrix strategy
EverlastingBugstopper Jun 10, 2021
3b7d36d
fix: don't strip symbols on windows
EverlastingBugstopper Jun 10, 2021
7a31cef
chore(ci): fix .exe
EverlastingBugstopper Jun 10, 2021
0cb5bbe
fix(ci): use bash shell for 7z
EverlastingBugstopper Jun 10, 2021
c82bc83
Edit suggestions for ARCHITECTURE and CONTRIBUTING (#610)
Jun 11, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config
@@ -0,0 +1,2 @@
[alias]
xtask = "run --package xtask --"
10 changes: 2 additions & 8 deletions .github/workflows/lint.yml
Expand Up @@ -40,11 +40,5 @@ jobs:
restore-keys: |
linux-stable-cargo-index-

- name: Check formatting
run: cargo fmt --all -- --check

- name: Check idiomatic code (composition-js)
run: cargo clippy --all -- -D warnings

- name: Check idiomatic code (no-composition)
run: cargo clippy --all --no-default-features -- -D warnings
- name: Lint
run: cargo xtask lint --verbose
116 changes: 57 additions & 59 deletions .github/workflows/release.yml
Expand Up @@ -31,15 +31,19 @@ jobs:
- build: linux-gnu
os: ubuntu-16.04
rust: stable
target: x86_64-unknown-linux-gnu
- build: linux-musl
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-musl
- build: macos
os: macos-latest
rust: stable
target: x86_64-apple-darwin
- build: windows
os: windows-latest
rust: stable
target: x86_64-pc-windows-msvc

outputs:
version: ${{ steps.get_version.outputs.version }}
Expand Down Expand Up @@ -79,64 +83,30 @@ jobs:
sudo apt update
sudo apt install musl-tools

- name: Build (GNU Linux)
if: matrix.build == 'linux-gnu'
run: |
rustup target add ${{ env.LINUX_GNU_TARGET }}
cargo build --release --target ${{ env.LINUX_GNU_TARGET }}
env:
OPENSSL_STATIC: 1
- name: Install Rust toolchain
run: rustup target add ${{ matrix.target }}

- name: Build (MUSL Linux)
if: matrix.build == 'linux-musl'
run: |
rustup target add ${{ env.LINUX_MUSL_TARGET }}
cargo build --release --no-default-features --target ${{ env.LINUX_MUSL_TARGET }}
env:
OPENSSL_STATIC: 1 # statically link OpenSSL

- name: Build (MacOS)
if: matrix.build == 'macos'
run: cargo build --release
env:
OPENSSL_DIR: /usr/local/opt/openssl@1.1 # don't use system install of LibreSSL
OPENSSL_STATIC: 1 # statically link OpenSSL

- name: Build (Windows)
if: matrix.build == 'windows'
run: cargo build --release
env:
RUSTFLAGS: -Ctarget-feature=+crt-static # fully static build
- name: Test
run: cargo xtask test --verbose --target ${{ matrix.target }}

- name: Build
run: cargo xtask dist --verbose --target ${{ matrix.target }}

- name: Populate artifact directory
shell: bash
run: |
mkdir ${{ env.RELEASE_DIR }} dist
mv ${{ env.RELEASE_ADDS }} ./dist

- name: Move binary to dist (MacOS)
if: matrix.build == 'macos'
- name: Move binary to dist
if: matrix.build != 'windows'
shell: bash
run: mv ./target/release/${{ env.RELEASE_BIN }} ./dist/${{ env.RELEASE_BIN }}

- name: Create tarball (GNU Linux)
if: matrix.build == 'linux-gnu'
run: |
mv ./target/${{ env.LINUX_GNU_TARGET }}/release/${{ env.RELEASE_BIN }} ./dist/${{ env.RELEASE_BIN }}
7z a -ttar -so -an ./dist | 7z a -si ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.version }}-${{ env.LINUX_GNU_TARGET }}.tar.gz

- name: Create tarball (MUSL Linux)
if: matrix.build == 'linux-musl'
run: |
mv ./target/${{ env.LINUX_MUSL_TARGET }}/release/${{ env.RELEASE_BIN }} ./dist/${{ env.RELEASE_BIN }}
7z a -ttar -so -an ./dist | 7z a -si ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.version }}-${{ env.LINUX_MUSL_TARGET }}.tar.gz
run: mv ./target/${{ matrix.target }}/release/${{ env.RELEASE_BIN }} ./dist/${{ env.RELEASE_BIN }}

- name: Create tarball (Windows)
if: matrix.build == 'windows'
- name: Move binary to dist (Windows)
if: matrix.build == 'windows'
shell: bash
run: |
mv ./target/release/${{ env.RELEASE_BIN }}.exe ./dist/${{ env.RELEASE_BIN }}.exe
7z a -ttar -so -an ./dist | 7z a -si ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.version }}-${{ env.WINDOWS_TARGET }}.tar.gz
run: mv ./target/${{ matrix.target }}/release/${{ env.RELEASE_BIN }}.exe ./dist/${{ env.RELEASE_BIN }}.exe

- name: Create build keychain (MacOS)
if: matrix.build == 'macos'
Expand Down Expand Up @@ -247,10 +217,10 @@ jobs:
echo "::debug::Notarization timed out after $RETRY_MINUTES minutes."
exit 1

- name: Create tarball (MacOS)
if: matrix.build == 'macos'
- name: Create Tarball
shell: bash
run: |
7z a -ttar -so -an ./dist | 7z a -si ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.version }}-${{ env.MACOS_TARGET }}.tar.gz
7z a -ttar -so -an ./dist | 7z a -si ./${{ env.RELEASE_DIR }}/${{ env.RELEASE_BIN }}-${{ steps.get_version.outputs.version }}-${{ matrix.target }}.tar.gz

- name: Upload Tarball
uses: actions/upload-artifact@v2
Expand All @@ -276,19 +246,49 @@ jobs:
- name: Unzip binaries
shell: bash
run: |
tar -xzvf ./linux/${{ env.RELEASE_BIN }}-${{ needs.build.outputs.version }}-${{ env.LINUX_GNU_TARGET }}.tar.gz && mv ./dist/${{ env.RELEASE_BIN }} ./linux-gnu-cli && rm -rf dist
tar -xzvf ./linux/${{ env.RELEASE_BIN }}-${{ needs.build.outputs.version }}-${{ env.LINUX_MUSL_TARGET }}.tar.gz && mv ./dist/${{ env.RELEASE_BIN }} ./linux-musl-cli && rm -rf dist
tar -xzvf ./linux-gnu/${{ env.RELEASE_BIN }}-${{ needs.build.outputs.version }}-${{ env.LINUX_GNU_TARGET }}.tar.gz && mv ./dist/${{ env.RELEASE_BIN }} ./linux-gnu-cli && rm -rf dist
tar -xzvf ./linux-musl/${{ env.RELEASE_BIN }}-${{ needs.build.outputs.version }}-${{ env.LINUX_MUSL_TARGET }}.tar.gz && mv ./dist/${{ env.RELEASE_BIN }} ./linux-musl-cli && rm -rf dist
tar -xzvf ./windows/${{ env.RELEASE_BIN }}-${{ needs.build.outputs.version }}-${{ env.WINDOWS_TARGET }}.tar.gz && mv ./dist/${{ env.RELEASE_BIN }}.exe ./windows-cli.exe && rm -rf dist
tar -xzvf ./macos/${{ env.RELEASE_BIN }}-${{ needs.build.outputs.version }}-${{ env.MACOS_TARGET }}.tar.gz && mv ./dist/${{ env.RELEASE_BIN }} ./macos-cli && rm -rf dist

- name: Hash binaries
id: get_shas
shell: bash
run: |
echo ::set-output name=linux-gnu-sha::"$(sha256sum -b linux-gnu-cli | cut -d ' ' -f1)"
echo ::set-output name=linux-musl-sha::"$(sha256sum -b linux-musl-cli | cut -d ' ' -f1)"
echo ::set-output name=windows-sha::"$(sha256sum -b windows-cli.exe | cut -d ' ' -f1)"
echo ::set-output name=macos-sha::"$(sha256sum -b macos-cli | cut -d ' ' -f1)"
LINUX_GNU_SHA="$(sha256sum -b linux-gnu-cli | cut -d ' ' -f1)"
LINUX_MUSL_SHA="$(sha256sum -b linux-musl-cli | cut -d ' ' -f1)"
WINDOWS_SHA="$(sha256sum -b windows-cli.exe | cut -d ' ' -f1)"
MACOS_SHA="$(sha256sum -b macos-cli | cut -d ' ' -f1)"
failed=0
if [ ${#LINUX_GNU_SHA} -ne 64 ]; then
((failed=$failed+1))
echo "::debug::\$LINUX_GNU_SHA has not been computed."
fi

if [ ${#LINUX_MUSL_SHA} -ne 64 ]; then
((failed=$failed+1))
echo "::debug::\$LINUX_MUSL_SHA has not been computed."
fi

if [ ${#WINDOWS_SHA} -ne 64 ]; then
((failed=$failed+1))
echo "::debug::\$WINDOWS_SHA has not been computed."
fi

if [ ${#MACOS_SHA} -ne 64 ]; then
((failed=$failed+1))
echo "::debug::\$MACOS_SHA has not been computed."
fi

if [ "$failed" -gt 0 ]; then
echo "::debug::Failed to compute $failed checksum(s)."
exit 1
fi

echo ::set-output name=linux-gnu-sha::"$LINUX_GNU_SHA"
echo ::set-output name=linux-musl-sha::"$LINUX_MUSL_SHA"
echo ::set-output name=windows-sha::"$WINDOWS_SHA"
echo ::set-output name=macos-sha::"$MACOS_SHA"

- name: Create Release
id: create_release
Expand All @@ -300,9 +300,7 @@ jobs:
release_name: ${{ needs.build.outputs.version }}
prerelease: ${{ env.is-prerelease }}
body: |
<!---
paste the changelog entry here!
-->
<!-- changelog -->
---
This release was automatically created by [Github Actions](./.github/workflows/release.yml).

Expand Down
27 changes: 11 additions & 16 deletions .github/workflows/test.yml
@@ -1,13 +1,22 @@
name: Tests

on: [push]
on:
push:
branches:
- "**"
# Tests are run in the release job on tag pushes -
# We don't need to run them twice.
tags-ignore:
- "v*"

jobs:
test:
name: Test

runs-on: ${{ matrix.os }}
continue-on-error: ${{ contains(matrix.build, 'nightly') }}
strategy:
fail-fast: false
matrix:
build:
[
Expand Down Expand Up @@ -91,19 +100,5 @@ jobs:
sudo apt update
sudo apt install musl-tools

# Test with `rover supergraph compose`
- name: Run Tests
if: (!startsWith(matrix.build, 'linux-musl-'))
run: |
cargo test --workspace --locked --target ${{ matrix.target }}
env:
RUST_BACKTRACE: 1


# Test without `rover supergraph compose`
- name: Run Tests
if: startsWith(matrix.build, 'linux-musl-')
run: |
cargo test --workspace --locked --target ${{ matrix.target }} --no-default-features
env:
RUST_BACKTRACE: 1
run: cargo xtask test --verbose --target ${{ matrix.target }}