Skip to content

Add option to fail on error when running with upload-to-github #475

Add option to fail on error when running with upload-to-github

Add option to fail on error when running with upload-to-github #475

Workflow file for this run

name: Rust
on:
push:
branches:
- master
tags:
- "**"
pull_request:
jobs:
pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
paths_result: ${{ steps.skip_check.outputs.paths_result }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@c449d86cf33a2a6c7a4193264cc2578e2c3266d4 # pin@v4
with:
paths_ignore: '["docs/**", "*.md"]'
build-linux:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true' || startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Toolchain
uses: oxidecomputer/actions-rs_toolchain@ad3f86084a8a5acf2c09cb691421b31cf8af7a36 # pin@oxide/master
- name: Cache
uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f # pin@v2
- name: Build
run: RUSTFLAGS='-C target-feature=+crt-static' cargo build --target x86_64-unknown-linux-gnu --all --release && ls target && mv target/x86_64-unknown-linux-gnu/release/squawk target/release/squawk-linux-x86_64
- name: Artifact
uses: actions/upload-artifact@v3
with:
name: release
path: target/release/squawk-linux-x86_64
- name: Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
target/release/squawk-linux-x86_64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# windows isn't supported by libpg_query
# https://github.com/lfittl/libpg_query/issues/44
build-mac:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true' || startsWith(github.ref, 'refs/tags/')
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Toolchain
uses: oxidecomputer/actions-rs_toolchain@ad3f86084a8a5acf2c09cb691421b31cf8af7a36 # pin@oxide/master
- name: Cache
uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f # pin@v2
- name: Build for mac
run: cargo build --all --release && mv target/release/squawk target/release/squawk-darwin-x86_64
- name: Artifact
uses: actions/upload-artifact@v3
with:
name: release
path: target/release/squawk-darwin-x86_64
- name: Release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # pin@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
target/release/squawk-darwin-x86_64
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-npm:
if: startsWith(github.ref, 'refs/tags/')
needs: [build-linux, build-mac]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
lint:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Toolchain
uses: oxidecomputer/actions-rs_toolchain@ad3f86084a8a5acf2c09cb691421b31cf8af7a36 # pin@oxide/master
- name: Cache
uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f # pin@v2
- name: Install Rust Fmt
run: rustup component add rustfmt
- name: Install Clippy
run: rustup component add clippy
- name: Get Clippy Version
run: cargo clippy --version
- name: Lint
run: ./s/lint
test:
needs: pre_job
if: needs.pre_job.outputs.should_skip != 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install Toolchain
uses: oxidecomputer/actions-rs_toolchain@ad3f86084a8a5acf2c09cb691421b31cf8af7a36 # pin@oxide/master
- name: Cache
uses: Swatinem/rust-cache@6fd3edff6979b79f87531400ad694fb7f2c84b1f # pin@v2
- name: Test
run: ./s/test
check_version:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version-file: ".python-version"
- name: Check versions are consistent
run: ./s/check-version