Skip to content

FabienD launch dctl tests #106

FabienD launch dctl tests

FabienD launch dctl tests #106

Workflow file for this run

name: dctl CI
run-name: ${{ github.actor }} launch dctl tests
on:
pull_request:
push:
branches:
- main
tags:
- '*.*.*'
jobs:
tests:
if: github.event_name == 'push' || github.event_name == 'pull_request'
name: Test and Code coverage
runs-on: ubuntu-latest
defaults:
run:
working-directory: cli
steps:
- uses: actions/checkout@v3
- name: install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Install grcov
run: rustup component add llvm-tools-preview && cargo install grcov
- name: "Prepare cache"
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
cli/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: run tests
run: cargo test
env:
RUSTFLAGS: '-Cinstrument-coverage'
- name: Run grcov
run: grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info
- name: upload coverage
uses: codecov/codecov-action@v3
with:
files: lcov.info
flags: unittests
name: codecov-dctl
fail_ci_if_error: true
verbose: true
tests_for_release:
if: startsWith(github.ref, 'refs/tags/')
name: Test and Build dctl
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: "ubuntu-latest"
target: x86_64-unknown-linux-gnu
- os: "ubuntu-latest"
target: x86_64-unknown-linux-musl
- os: "macos-latest"
target: x86_64-apple-darwin
- os: "macos-latest"
target: aarch64-apple-darwin
- os: "windows-latest"
target: x86_64-pc-windows-msvc
- os: "windows-latest"
target: x86_64-pc-windows-gnu
defaults:
run:
working-directory: cli
steps:
- uses: actions/checkout@v3
- name: install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: "Prepare cache"
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
cli/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
# Install target
- name: install target
run: rustup target add ${{ matrix.target }}
# Test
- name: run tests --release
run: cargo test --release
# Build only on tag
- name: run build --release
run: cargo build --release --target ${{ matrix.target }}
# Save build
- if: runner.os != 'Windows'
name: Tar files
run: tar cvf dctl-${{ runner.os }}-${{ matrix.target }}.tar ./target/${{ matrix.target }}/release/dctl
- if: runner.os == 'Windows'
name: Tar files
run: tar cvf dctl-${{ runner.os }}-${{ matrix.target }}.tar ./target/${{ matrix.target }}/release/dctl.exe
- name: save compressed build
uses: actions/upload-artifact@v3
with:
name: dctl-${{ runner.os }}-${{ matrix.target }}.tar
path: cli/dctl-${{ runner.os }}-${{ matrix.target }}.tar
retention-days: 1
release:
name: Create Release
runs-on: ubuntu-latest
needs: tests_for_release
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v3
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: if ${{ github.event_name == 'pull_request' }} then true else false
prerelease: if ${{ startsWith(github.ref, 'refs/tags/rc*') }} then true else false
upload_artifacts:
name: Upload Release Assets
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: "ubuntu-latest"
target: x86_64-unknown-linux-gnu
- os: "ubuntu-latest"
target: x86_64-unknown-linux-musl
- os: "macos-latest"
target: x86_64-apple-darwin
- os: "macos-latest"
target: aarch64-apple-darwin
- os: "windows-latest"
target: x86_64-pc-windows-msvc
- os: "windows-latest"
target: x86_64-pc-windows-gnu
needs: release
steps:
- name: Download Release Asset
uses: actions/download-artifact@v3
with:
name: dctl-${{ runner.os }}-${{ matrix.target }}.tar
- name: Upload Release Assets
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_name: dctl-${{ runner.os }}-${{ matrix.target }}.tar
asset_path: ./dctl-${{ runner.os }}-${{ matrix.target }}.tar
asset_content_type: application/octet-stream