From baf0d5a61b8372151d74affd5e834344ceee823a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 4 Dec 2020 10:00:42 +0100 Subject: [PATCH] CI: optimize and fix release workflow --- .github/workflows/release.yml | 31 ++++++++++++++++++++++++++++--- .github/workflows/test.yml | 32 +++++++++++++++++++------------- ci/make_release.py | 2 +- 3 files changed, 48 insertions(+), 17 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1f181ab..6c1e268 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Make release +name: Create release on: workflow_dispatch: @@ -11,13 +11,13 @@ on: required: true jobs: - build: + create-release: runs-on: ubuntu-latest steps: - name: Checkout sources uses: actions/checkout@v2 with: - ref: github.event.inputs.sha + ref: ${{ github.event.inputs.sha }} - name: Install stable toolchain uses: actions-rs/toolchain@v1 @@ -26,8 +26,33 @@ jobs: toolchain: stable override: true + - uses: Swatinem/rust-cache@v1 + - name: Build uses: actions-rs/cargo@v1 with: command: build args: --release + + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.event.inputs.tag }} + release_name: ${{ github.event.inputs.tag }} + body: RSDS release ${{ github.event.inputs.tag }} + commitish: ${{ github.event.inputs.sha }} + draft: false + prerelease: false + + - name: Upload scheduler binary + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./target/release/rsds-scheduler + asset_name: rsds-scheduler + asset_content_type: application/exe diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 181bccb..29e3572 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,7 +4,11 @@ # for simplicity we are compiling and testing everything on the Ubuntu environment only. # For multi-OS testing see the `cross.yml` workflow. -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: name: Test @@ -24,6 +28,8 @@ jobs: override: true components: rustfmt, clippy + - uses: Swatinem/rust-cache@v1 + - name: Build uses: actions-rs/cargo@v1 with: @@ -34,18 +40,6 @@ jobs: with: command: test - #- name: Lint - # uses: actions-rs/cargo@v1 - # with: - # command: clippy - # args: -- -D warnings - - - name: Formatting - uses: actions-rs/cargo@v1 - with: - command: fmt - args: --all -- --check - - name: Setup Python uses: actions/setup-python@v1 with: @@ -59,3 +53,15 @@ jobs: - name: Test Python run: python -m pytest tests + + - name: Lint + uses: actions-rs/cargo@v1 + with: + command: clippy + args: -- -D warnings + + - name: Formatting + uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check diff --git a/ci/make_release.py b/ci/make_release.py index 2cb213e..95a5e25 100644 --- a/ci/make_release.py +++ b/ci/make_release.py @@ -11,7 +11,7 @@ def send_github_event(workflow_name: str, token: str, inputs=()): if inputs is None: inputs = {} - payload = {"ref": "ci", "inputs": inputs} + payload = {"ref": "master", "inputs": inputs} headers = {"Authorization": f"token {token}", "Accept": "application/vnd.github.v3+json"} response = requests.post(