Skip to content

ci: remove unneeded workflows #2

ci: remove unneeded workflows

ci: remove unneeded workflows #2

Workflow file for this run

on:
workflow_call:
inputs:
matrix-args:
required: false
type: string
description: Arguments to pass to `cargo xtask ci-job target-matrix`
checkout-ref:
required: false
type: string
description: Used to checkout a specific ref, instead of the default ref with `actions/checkout` action
pull_request:
merge_group:
push:
branches: [main, staging, trying]
tags:
- "v*.*.*"
name: CI
env:
CARGO_NET_RETRY: 3
CARGO_HTTP_CHECK_REVOKE: false
jobs:
check:
runs-on: ubuntu-latest
outputs:
is-latest: ${{ steps.check.outputs.is-latest }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-ref }}
- uses: ./.github/actions/setup-rust
- run: cargo xtask ci-job check
id: check
generate-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.generate-matrix.outputs.matrix }}
tests: ${{ steps.generate-matrix.outputs.tests }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-ref }}
- uses: ./.github/actions/setup-rust
- name: Generate matrix
id: generate-matrix
run: cargo xtask ci-job target-matrix ${{ github.event_name == 'merge_group' && format('--merge-group {0}', github.ref) || '' }} ${{ inputs.matrix-args || '' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
name: target (${{ matrix.pretty }},${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: [generate-matrix]
if: (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'merge_group' || github.event_name == 'issue_comment' || github.event_name == 'schedule') && needs.generate-matrix.outputs.matrix != '{}' && needs.generate-matrix.outputs.matrix != '[]' && needs.generate-matrix.outputs.matrix != ''
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.pretty }}
cancel-in-progress: false
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.generate-matrix.outputs.matrix) }}
outputs:
has-image: ${{ steps.prepare-meta.outputs.has-image }}
images: ${{ steps.build-docker-image.outputs.images && fromJSON(steps.build-docker-image.outputs.images) }}
coverage-artifact: ${{ steps.cov.outputs.artifact-name }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.checkout-ref }}
- uses: ./.github/actions/setup-rust
- name: Set up Docker Buildx
if: runner.os == 'Linux'
uses: docker/setup-buildx-action@v2
- name: Build xtask
run: cargo build -p xtask
- name: Prepare Meta
id: prepare-meta
timeout-minutes: 60
run: cargo xtask ci-job prepare-meta "${TARGET}${SUB:+.$SUB}"
env:
TARGET: ${{ matrix.target }}
SUB: ${{ matrix.sub }}
shell: bash
- name: LLVM instrument coverage
id: cov
uses: ./.github/actions/cargo-llvm-cov
if: steps.prepare-meta.outputs.has-image && steps.prepare-meta.outputs.test-variant != 'zig'
with:
name: cross-${{matrix.pretty}}
- name: Install cross
if: matrix.deploy
run: cargo install --path . --force --debug
- name: Docker Meta
if: steps.prepare-meta.outputs.has-image
id: docker-meta
uses: docker/metadata-action@v4
with:
images: |
name=${{ steps.prepare-meta.outputs.image }}
labels: |
${{ fromJSON(steps.prepare-meta.outputs.labels) }}
- name: Build Docker image
id: build-docker-image
if: steps.prepare-meta.outputs.has-image
timeout-minutes: 120
run: cargo xtask build-docker-image -v "${TARGET}${SUB:+.$SUB}" ${{ matrix.verbose && '-v' || '' }}
env:
TARGET: ${{ matrix.target }}
SUB: ${{ matrix.sub }}
LABELS: ${{ steps.docker-meta.outputs.labels }}
LATEST: ${{ needs.check.outputs.is-latest || 'false' }}
shell: bash
- name: Set Docker image for test
if: steps.prepare-meta.outputs.has-image
run: |
TARGET_VAR="cross_target_${TARGET//-/_}_image"
echo "${TARGET_VAR^^}=${IMAGE}" | tee -a "${GITHUB_ENV}"
env:
TARGET: ${{ matrix.target }}
IMAGE: ${{ steps.build-docker-image.outputs.image }}
shell: bash
- name: Login to GitHub Container Registry
if: steps.prepare-meta.outputs.has-image
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push image to GitHub Container Registry
if: >
(github.event_name == 'push' || github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') &&
steps.prepare-meta.outputs.has-image && (
github.ref == format('refs/heads/{0}', github.event.repository.default_branch) ||
startsWith(github.ref, 'refs/tags/v')
)
run: cargo xtask build-docker-image -v --push "${TARGET}${SUB:+.$SUB}"
env:
TARGET: ${{ matrix.target }}
SUB: ${{ matrix.sub }}
LABELS: ${{ steps.docker-meta.outputs.labels }}
LATEST: ${{ needs.check.outputs.is-latest || 'false' }}
shell: bash