This commit is contained in:
Elijah McMorris 2023-11-15 08:30:35 -08:00 committed by NexVeridian
parent 5f3c11efb1
commit ae5c9ac098
Signed by: NexVeridian
SSH key fingerprint: SHA256:bsA1SKZxuEcEVHAy3gY1HUeM5ykRJl0U0kQHQn0hMg8
2 changed files with 122 additions and 54 deletions

109
.github/workflows/docker.yml vendored Normal file
View file

@ -0,0 +1,109 @@
name: Docker
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
workflow_run:
workflows: [nextest]
branches: [main]
types:
- completed
# schedule:
# - cron: 0 0 * * 1
# push:
# branches: [ "main" ]
# # Publish semver tags as releases.
# tags: [ 'v*.*.*' ]
# pull_request:
# branches: [ "main" ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#running-a-workflow-based-on-the-conclusion-of-another-workflow
if: ${{ github.event.workflow_run.conclusion == 'success' }}
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
with:
cosign-release: "v2.1.1"
# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# https://github.com/orgs/community/discussions/25768#discussioncomment-3249183
- name: downcase REPO
run: |
echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
# tags: ${{ steps.meta.outputs.tags }}
# tags: ${{ env.REGISTRY }}/${{ github.repository }}:latest
tags: ${{ env.REGISTRY }}/${{ env.REPO }}:latest
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# # Sign the resulting Docker image digest except on PRs.
# # This will only write to the public Rekor transparency log when the Docker
# # repository is public to avoid leaking data. If you would like to publish
# # transparency data even for private images, pass --force to cosign below.
# # https://github.com/sigstore/cosign
# - name: Sign the published Docker image
# if: ${{ github.event_name != 'pull_request' }}
# env:
# # https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
# TAGS: ${{ steps.meta.outputs.tags }}
# DIGEST: ${{ steps.build-and-push.outputs.digest }}
# # This step uses the identity token to provision an ephemeral certificate
# # against the sigstore community Fulcio instance.
# run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

View file

@ -1,72 +1,31 @@
# See workflow runs at https://github.com/nextest-rs/reuse-build-partition-example/actions/workflows/ci.yml.
# https://github.com/nextest-rs/reuse-build-partition-example
# https://keliris.dev/articles/setup-rust-github-actions
name: nextest
on:
# pull_request:
# branches: [main]
pull_request:
branches: [main]
push:
branches: [main]
schedule:
# Run this every day at 00:00 UTC.
- cron: 0 0 * * *
- cron: 0 0 * * 1
env:
CARGO_TERM_COLOR: always
jobs:
build-test-artifacts:
name: Build test artifacts
run-tests:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# By default actions/checkout checks out a merge commit. Check out the PR head instead.
# https://github.com/actions/checkout#checkout-pull-request-head-commit-instead-of-merge-commit
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- uses: actions/checkout@v3
# - uses: rui314/setup-mold@v1
- name: clang
- name: install mold
run: sudo apt-get install -y musl-tools musl-dev libssl-dev clang mold
- name: Install nextest
uses: taiki-e/install-action@nextest
- name: Build and archive tests
run: cargo nextest archive --archive-file nextest-archive.tar.zst
- name: Upload archive to workflow
uses: actions/upload-artifact@v3
# https://github.com/moonrepo/setup-rust
- uses: moonrepo/setup-rust@v1
with:
name: nextest-archive
path: nextest-archive.tar.zst
run-tests-partitioned:
name: Run tests with partitioning
runs-on: ubuntu-latest
needs: build-test-artifacts
strategy:
matrix:
partition: [1, 2]
steps:
# The source directory must be checked out.
- uses: actions/checkout@v2
with:
# By default actions/checkout checks out a merge commit. Check out the PR head instead.
# https://github.com/actions/checkout#checkout-pull-request-head-commit-instead-of-merge-commit
ref: ${{ github.event.pull_request.head.sha }}
# In this example, the Rust toolchain is not installed. cargo nextest's run phase does not
# require Cargo. You can choose to install Rust if your tests require it, of course.
# Instead, create ~/.cargo/bin as required by the install action.
- run: mkdir -p ~/.cargo/bin
- name: Install nextest
uses: taiki-e/install-action@nextest
- name: Download archive
uses: actions/download-artifact@v3
with:
name: nextest-archive
bins: cargo-nextest
- name: Run tests
run: |
~/.cargo/bin/cargo-nextest nextest run --archive-file nextest-archive.tar.zst \
--partition count:${{ matrix.partition }}/2 \
-E "all() - test(get_api) - kind(bin)"
run: cargo nextest run -E "all() - test(get_api) - kind(bin)"