Skip to content

Commit

Permalink
ci/cd update
Browse files Browse the repository at this point in the history
  • Loading branch information
deepu105 committed Jan 22, 2024
1 parent c92209a commit 7d9a442
Show file tree
Hide file tree
Showing 4 changed files with 175 additions and 128 deletions.
118 changes: 55 additions & 63 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ jobs:
steps:
- name: Create artifacts directory
run: mkdir artifacts

- name: Get the release version from the tag
if: env.VERSION == ''
run: |
Expand All @@ -22,16 +21,12 @@ jobs:
else
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
fi
- name: Validate version environment variable
run: |
echo "Version being built against is version ${{ env.VERSION }}"!
run: echo "Version being built against is version ${{ env.VERSION }}"!
- name: Save version number to artifact
run: echo "${{ env.VERSION }}" > artifacts/release-version

- name: Upload artifacts
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: artifacts
path: artifacts
Expand All @@ -45,56 +40,63 @@ jobs:
strategy:
fail-fast: false
matrix:
# prettier-ignore
job:
# prettier-ignore
- { name: "macOS-arm64", os: "macOS-latest", target: "aarch64-apple-darwin", artifact_prefix: "macos-arm64", use-cross: true }
- { name: "macOS-amd64", os: "macOS-latest", target: "x86_64-apple-darwin", artifact_prefix: "macos" }
- { name: "windows-amd64", os: "windows-latest", target: "x86_64-pc-windows-msvc", artifact_prefix: "windows" }
- { name: "windows-aarch64", os: "windows-latest", target: "aarch64-pc-windows-msvc", artifact_prefix: "windows-aarch64", use-cross: true }
- { name: "linux-gnu", os: "ubuntu-latest", target: "x86_64-unknown-linux-gnu", artifact_prefix: "linux" }
- { name: "linux-musl", os: "ubuntu-latest", target: "x86_64-unknown-linux-musl", artifact_prefix: "linux-musl", use-cross: true, }
- { name: "aarch64-gnu", os: "ubuntu-latest", target: "aarch64-unknown-linux-gnu", artifact_prefix: "aarch64-gnu", use-cross: true, test-bin: "--bin kdash" }
- { name: "aarch64-musl", os: "ubuntu-latest", target: "aarch64-unknown-linux-musl", artifact_prefix: "aarch64-musl", use-cross: true, test-bin: "--bin kdash" }
- { name: "arm-gnu", os: "ubuntu-latest", target: "arm-unknown-linux-gnueabihf", artifact_prefix: "armv6-gnu", use-cross: true, test-bin: "--bin kdash" }
- { name: "arm-musl", os: "ubuntu-latest", target: "arm-unknown-linux-musleabihf", artifact_prefix: "armv6-musl", use-cross: true, test-bin: "--bin kdash" }
- { name: "armv7-gnu", os: "ubuntu-latest", target: "armv7-unknown-linux-gnueabihf", artifact_prefix: "armv7-gnu", use-cross: true, test-bin: "--bin kdash" }
- { name: "armv7-musl", os: "ubuntu-latest", target: "armv7-unknown-linux-musleabihf", artifact_prefix: "armv7-musl", use-cross: true, test-bin: "--bin kdash" }
- { name: "macOS-arm64", os: "macOS-latest", target: "aarch64-apple-darwin", artifact_prefix: "macos-arm64", use-cross: true }
- { name: "macOS-amd64", os: "macOS-latest", target: "x86_64-apple-darwin", artifact_prefix: "macos" }
- { name: "windows-amd64", os: "windows-latest", target: "x86_64-pc-windows-msvc", artifact_prefix: "windows" }
- { name: "windows-aarch64", os: "windows-latest", target: "aarch64-pc-windows-msvc", artifact_prefix: "windows-aarch64", use-cross: true }
- { name: "linux-gnu", os: "ubuntu-latest", target: "x86_64-unknown-linux-gnu", artifact_prefix: "linux" }
- { name: "linux-musl", os: "ubuntu-latest", target: "x86_64-unknown-linux-musl", artifact_prefix: "linux-musl", use-cross: true, }
- { name: "linux-aarch64-gnu", os: "ubuntu-latest", target: "aarch64-unknown-linux-gnu", artifact_prefix: "aarch64-gnu", use-cross: true, test-bin: "--bin kdash" }
- { name: "linux-aarch64-musl", os: "ubuntu-latest", target: "aarch64-unknown-linux-musl", artifact_prefix: "aarch64-musl", use-cross: true, test-bin: "--bin kdash" }
- { name: "linux-arm-gnu", os: "ubuntu-latest", target: "arm-unknown-linux-gnueabihf", artifact_prefix: "armv6-gnu", use-cross: true, test-bin: "--bin kdash" }
- { name: "linux-arm-musl", os: "ubuntu-latest", target: "arm-unknown-linux-musleabihf", artifact_prefix: "armv6-musl", use-cross: true, test-bin: "--bin kdash" }
- { name: "linux-armv7-gnu", os: "ubuntu-latest", target: "armv7-unknown-linux-gnueabihf", artifact_prefix: "armv7-gnu", use-cross: true, test-bin: "--bin kdash" }
- { name: "linux-armv7-musl", os: "ubuntu-latest", target: "armv7-unknown-linux-musleabihf", artifact_prefix: "armv7-musl", use-cross: true, test-bin: "--bin kdash" }
rust: [stable]

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1

- uses: actions/cache@v3
name: Cache Cargo registry
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }}
- uses: actions/cache@v3
if: startsWith(matrix.job.name, 'linux-')
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-bin-${{ hashFiles('.github/workflows/cd.yml') }}
- name: Get shared artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: artifacts
path: artifacts

- name: Set release version
shell: bash
run: |
release_version="$(cat ./artifacts/release-version)"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
- name: Validate release environment variables
run: |
echo "Release version: ${{ env.RELEASE_VERSION }}"
- name: Install toolchain
uses: actions-rs/toolchain@v1
- uses: dtolnay/rust-toolchain@stable
name: Set Rust toolchain
with:
targets: ${{ matrix.job.target }}
- uses: taiki-e/setup-cross-toolchain-action@v1
with:
toolchain: ${{ matrix.rust }}
override: true
# NB: sets CARGO_BUILD_TARGET evar - do not need --target flag in build
target: ${{ matrix.job.target }}
profile: minimal # minimal component installation (ie, no documentation)

- uses: taiki-e/install-action@cross
if: ${{ matrix.job.cross }}
- name: Installing needed macOS dependencies
if: matrix.job.os == 'macos-latest'
run: brew install [email protected]

- name: Installing needed Ubuntu dependencies
if: matrix.job.os == 'ubuntu-latest'
shell: bash
Expand All @@ -107,26 +109,14 @@ jobs:
esac
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.job.use-cross }}
command: build
args: --release --verbose --target=${{ matrix.job.target }}
toolchain: ${{ matrix.rust }}

run: cargo build --release --verbose --target=${{ matrix.job.target }} --locked
- name: Verify file
shell: bash
run: |
file target/${{ matrix.job.target }}/release/kdash
ldd target/${{ matrix.job.target }}/release/kdash
- name: Test
if: matrix.job.target != 'aarch64-apple-darwin'
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.job.use-cross }}
command: test
args: --target=${{ matrix.job.target }} ${{ matrix.job.test-bin }}
run: cargo test --release --verbose --target=${{ matrix.job.target }} ${{ matrix.job.test-bin }}

- name: Packaging final binary (Windows)
if: matrix.job.os == 'windows-latest'
Expand All @@ -149,7 +139,7 @@ jobs:
# set the right strip executable
STRIP="strip";
case ${{ matrix.job.target }} in
arm-*-linux-*) STRIP="arm-linux-gnueabihf-strip" ;;
arm*-linux-*) STRIP="arm-linux-gnueabihf-strip" ;;
aarch64-*-linux-*) STRIP="aarch64-linux-gnu-strip" ;;
esac;
cd target/${{ matrix.job.target }}/release
Expand All @@ -176,7 +166,7 @@ jobs:
cp target/${{ matrix.job.target }}/release/${{ env.RELEASE_NAME }}.sha256 artifacts/
- name: Upload artifacts
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v4
with:
name: artifacts
path: artifacts
Expand All @@ -187,12 +177,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Get release artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: artifacts
path: artifacts
Expand Down Expand Up @@ -238,12 +228,12 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Get release artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: artifacts
path: artifacts
Expand Down Expand Up @@ -302,7 +292,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Get release artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: artifacts
path: artifacts
Expand Down Expand Up @@ -332,16 +322,18 @@ jobs:
needs: [build-release-artifacts]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@v4
- uses: actions/cache@v3
name: Cache Cargo registry
with:
toolchain: stable
override: true
profile: minimal # minimal component installation (ie, no documentation)
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }}
- uses: actions/cache@v3
with:
path: ~/.cargo/bin
key: ${{ runner.os }}-cargo-bin-${{ hashFiles('.github/workflows/cd.yml') }}
- uses: dtolnay/rust-toolchain@stable
- run: |
sudo apt-get update
sudo apt-get install -y -qq pkg-config libssl-dev libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
- uses: actions-rs/cargo@v1
with:
command: publish
args: --token ${{ secrets.CARGO_API_KEY }} --allow-dirty
- run: cargo publish --token ${{ secrets.CARGO_API_KEY }} --allow-dirty
60 changes: 30 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,31 @@ jobs:
needs: prepare
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
- uses: actions/cache@v3
name: Cache Cargo registry
with:
toolchain: stable
profile: minimal
override: true
- uses: actions-rs/cargo@v1
with:
command: check
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }}
- uses: dtolnay/rust-toolchain@stable
name: Set Rust toolchain
- run: cargo check --all --all-targets --workspace

test:
name: Test Suite
runs-on: ubuntu-latest
needs: prepare
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
- uses: actions/cache@v3
name: Cache Cargo registry
with:
toolchain: nightly
profile: minimal
override: true
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }}
- uses: dtolnay/rust-toolchain@stable
name: Set Rust toolchain
# These dependencies are required for `clipboard`
- run: sudo apt-get install -y -qq libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev
- uses: actions-rs/cargo@v1
with:
command: test
- run: cargo test
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Cpanic=abort -Zpanic_abort_tests'
Expand All @@ -70,32 +70,32 @@ jobs:
needs: prepare
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
- uses: actions/cache@v3
name: Cache Cargo registry
with:
toolchain: stable
profile: minimal
override: true
components: rustfmt
- uses: actions-rs/cargo@v1
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }}
- uses: dtolnay/rust-toolchain@stable
name: Set Rust toolchain
with:
command: fmt
args: --all -- --check
components: rustfmt
- run: cargo fmt --all -- --check

clippy:
name: Clippy
runs-on: ubuntu-latest
needs: prepare
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
- uses: actions/cache@v3
name: Cache Cargo registry
with:
toolchain: stable
profile: minimal
override: true
components: clippy
- uses: actions-rs/cargo@v1
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('Cargo.lock') }}
- uses: dtolnay/rust-toolchain@stable
name: Set Rust toolchain
with:
command: clippy
args: --all --all-features --all-targets --workspace -- -D warnings
components: clippy
- run: cargo clippy --all --all-features --all-targets --workspace -- -D warnings
env:
CARGO_INCREMENTAL: '0'
Loading

0 comments on commit 7d9a442

Please sign in to comment.