Build, Test, Lint & Package #49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build, Test, Lint & Package | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| release: | |
| type: boolean | |
| description: 'Build with release profile' | |
| default: false | |
| workflow_call: | |
| inputs: | |
| release: | |
| type: boolean | |
| default: false | |
| outputs: | |
| build: | |
| value: ${{ jobs.build.outputs.build }} | |
| tests: | |
| value: ${{ jobs.build.outputs.tests }} | |
| clippy: | |
| value: ${{ jobs.build.outputs.clippy }} | |
| format: | |
| value: ${{ jobs.build.outputs.format }} | |
| doc: | |
| value: ${{ jobs.build.outputs.doc }} | |
| shear: | |
| value: ${{ jobs.build.outputs.shear }} | |
| artifact-url: | |
| value: ${{ jobs.build.outputs.artifact-url }} | |
| version: | |
| value: ${{ jobs.build.outputs.version }} | |
| jobs: | |
| build: | |
| name: Build, Test, Lint and Package | |
| runs-on: ubuntu-latest | |
| outputs: | |
| build: ${{ steps.build.outcome }} | |
| tests: ${{ steps.tests.outcome }} | |
| clippy: ${{ steps.clippy.outcome }} | |
| format: ${{ steps.format.outcome }} | |
| doc: ${{ steps.doc.outcome }} | |
| shear: ${{ steps.shear.outcome }} | |
| version: ${{ steps.create-artifacts.outputs.VERSION}} | |
| artifact-url: ${{ steps.upload-x86.outputs.artifact-url }} | |
| env: | |
| build-type: ${{ inputs.release && 'release' || 'dev' }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Restore cached cargo dependencies | |
| id: deps-cache | |
| if: ${{ !inputs.release }} | |
| uses: actions/cache/restore@v5 | |
| with: | |
| path: | | |
| ~/.cargo/ | |
| target/ | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Install dependencies | |
| if: steps.deps-cache.outputs.cache-hit != 'true' | |
| run: | | |
| # TODO: rustup target add aarch64-unknown-linux-gnu | |
| # Linting tools | |
| cargo install cargo-shear | |
| cargo fetch --locked | |
| - name: Build | |
| id: build | |
| if: always() | |
| run: cargo build --profile ${{ env.build-type }} --locked | |
| - name: Tests | |
| id: tests | |
| if: always() | |
| run: cargo test --profile ${{ env.build-type }} --locked | |
| - name: Clippy | |
| id: clippy | |
| if: always() | |
| run: cargo clippy --profile ${{ env.build-type }} --no-deps --locked -- --deny warnings | |
| - name: Format | |
| id: format | |
| if: always() | |
| run: cargo fmt -- --check | |
| - name: Doc | |
| id: doc | |
| if: always() | |
| env: | |
| CARGO_BUILD_RUSTDOCFLAGS: "--deny warnings" | |
| run: cargo doc --profile ${{ env.build-type }} --document-private-items --no-deps --locked | |
| - name: Shear | |
| if: always() | |
| id: shear | |
| run: cargo shear | |
| - name: Create artifacts | |
| id: create-artifacts | |
| if: ${{ steps.build.outcome == 'success' }} | |
| run: | | |
| version=$(cargo pkgid | sed 's/.*#//') | |
| echo "VERSION=$version" >> "$GITHUB_OUTPUT" | |
| if [ "${{ env.build-type }}" == "release" ]; then | |
| buildtype="release" | |
| else | |
| buildtype="debug" | |
| fi | |
| artifact_x86=linux-enable-ir-emitter-${version}-${buildtype}-x86-64.tar.gz | |
| echo "ARTIFACT_X86=$artifact_x86" >> "$GITHUB_ENV" | |
| tar -czvf ${artifact_x86} -C target/${buildtype} linux-enable-ir-emitter | |
| - name: Upload x86 | |
| id: upload-x86 | |
| if: ${{ steps.build.outcome == 'success' }} | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ env.ARTIFACT_X86 }} | |
| path: ${{ env.ARTIFACT_X86 }} | |
| if-no-files-found: error | |
| - name: Save cached cargo dependencies | |
| if: steps.deps-cache.outputs.cache-hit != 'true' | |
| uses: actions/cache/save@v5 | |
| with: | |
| path: | | |
| ~/.cargo/ | |
| target/ | |
| key: ${{ steps.deps-cache.outputs.cache-primary-key }} |