Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions .devcontainer/Dockerfile.alpine

This file was deleted.

5 changes: 0 additions & 5 deletions .devcontainer/devcontainer.json

This file was deleted.

2 changes: 0 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,3 @@ These aren't hard requirements, just guidelines

- [ ] New/modified Rust code formatted with `cargo fmt`
- [ ] Documentation and `README.md` updated for this change, if necessary
- [ ] `CHANGELOG.md` updated for this change

128 changes: 128 additions & 0 deletions .github/workflows/build-artifacts.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Build Artifacts
on:
workflow_call:
inputs:
runner:
description: GitHub-hosted runner label
required: true
type: string
toolchain:
description: Rust toolchain channel to install
required: true
type: string
artifact_glob:
description: Glob pattern for build artifacts produced by build.sh
required: true
type: string
artifact_name:
description: Name to use when uploading artifacts
required: true
type: string
upload_artifact:
description: Whether to upload build artifacts
required: true
type: boolean
run_tests:
description: Run cargo test before building
required: false
type: boolean
default: false
allow_failure:
description: Treat build/test failures as non-fatal
required: false
type: boolean
default: false
rpm:
description: Generate an RPM artifact (Linux only)
required: false
type: boolean
default: false
release_version:
description: Release version to prepare with semantic-release-cargo
required: false
type: string
default: ""
fetch_depth:
description: Fetch depth for the checkout step
required: false
type: string
default: "0"

jobs:
build:
runs-on: ${{ inputs.runner }}
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: ${{ inputs.fetch_depth }}

- name: Setup Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ inputs.toolchain }}
- name: Rust Cache
uses: Swatinem/rust-cache@v2.8.1
- name: Install musl toolchain
if: ${{ inputs.rpm }}
run: |
set -euxo pipefail
sudo apt-get update
sudo apt-get install -y musl-tools
rustup target add x86_64-unknown-linux-musl
echo "CARGO_BUILD_TARGET=x86_64-unknown-linux-musl" >> $GITHUB_ENV

- name: Run tests
if: ${{ inputs.run_tests }}
continue-on-error: ${{ inputs.allow_failure }}
run: cargo test --all-features

- name: Install cargo-get
run: cargo install --locked cargo-get

- name: Install semantic-release-cargo
if: ${{ inputs.release_version != '' }}
run: cargo install --locked semantic-release-cargo

- name: Install cargo-generate-rpm
if: ${{ inputs.rpm }}
run: cargo install --locked cargo-generate-rpm

- name: Prepare release version
if: ${{ inputs.release_version != '' }}
run: semantic-release-cargo prepare ${{ inputs.release_version }}

- name: Build artifacts
id: build
continue-on-error: ${{ inputs.allow_failure }}
run: ./build.sh
env:
RUNNER: ${{ inputs.runner }}

- name: Generate RPM
if: ${{ inputs.rpm && steps.build.outcome == 'success' }}
run: |
cargo generate-rpm --target ${CARGO_BUILD_TARGET}

- name: Collect archives
if: ${{ steps.build.outcome == 'success' }}
run: |
set -euxo pipefail
rm -rf dist
mkdir dist
mv ${{ inputs.artifact_glob }} dist/

- name: Collect RPM
if: ${{ inputs.rpm && steps.build.outcome == 'success' }}
run: |
set -euxo pipefail
find target/ -name "floki*.rpm" -exec cp -v "{}" dist/ \;

- name: Upload artifacts
if: ${{ inputs.upload_artifact && steps.build.outcome == 'success' }}
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact_name }}
path: dist
216 changes: 62 additions & 154 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
name: floki-ci
on:
push:
tags:
# Full version
- "[0-9]+.[0-9]+.[0-9]+"
# Prerelease version
- "[0-9]+.[0-9]+.[0-9]+-*"
branches:
- main

pull_request:
branches:
Expand All @@ -23,172 +20,83 @@ jobs:
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Rust Cache
uses: Swatinem/rust-cache@v2.8.1
- name: Run cargo clippy to pick up any errors
run: cargo clippy --all-targets -- -Dwarnings
- name: Check code is formatted
run: cargo fmt -- --check

build:
name: Build static binary for publishing
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
name: Build ${{ matrix.name }}
strategy:
matrix:
os:
- ubuntu-24.04
- macos-latest
rust:
- stable
- beta
experimental: [false]
include:
- os: ubuntu-24.04
- name: linux-stable
os: ubuntu-24.04
rust: stable
artifact_glob: floki-*.tar.gz
artifact_name: dist-linux
upload_artifact: true
rpm: true
allow_failure: false
- name: linux-beta
os: ubuntu-24.04
rust: beta
artifact_glob: floki-*.tar.gz
artifact_name: linux-beta
upload_artifact: false
rpm: false
allow_failure: false
- name: linux-nightly
os: ubuntu-24.04
rust: nightly
experimental: true
steps:
- uses: actions/checkout@v5
- name: Install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: Install cargo-get
run: cargo install cargo-get
- name: Run tests
run: cargo test --all-features
- run: "./build.sh"
env:
OS_NAME: ${{ matrix.os }}
- name: Archive artifacts
uses: actions/upload-artifact@v5
if: ${{ matrix.rust == 'stable' }}
with:
name: stableartifacts-${{ matrix.os }}
path: |
floki*.zip
floki*.tar.gz
artifact_glob: floki-*.tar.gz
artifact_name: linux-nightly
upload_artifact: false
rpm: false
allow_failure: true
- name: macos-stable
os: macos-latest
rust: stable
artifact_glob: floki-*.zip
artifact_name: dist-macos
upload_artifact: true
rpm: false
allow_failure: false
- name: macos-beta
os: macos-latest
rust: beta
artifact_glob: floki-*.zip
artifact_name: macos-beta
upload_artifact: false
rpm: false
allow_failure: false
uses: ./.github/workflows/build-artifacts.yml
with:
runner: ${{ matrix.os }}
toolchain: ${{ matrix.rust }}
artifact_glob: ${{ matrix.artifact_glob }}
artifact_name: ${{ matrix.artifact_name }}
upload_artifact: ${{ matrix.upload_artifact }}
run_tests: true
rpm: ${{ matrix.rpm }}
allow_failure: ${{ matrix.allow_failure }}
fetch_depth: '1'


rpm:
name: Build and test RPM using cargo generate-rpm
name: Verify RPM installation
runs-on: ubuntu-24.04
needs: build
steps:
- uses: actions/checkout@v5
- name: Install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Install cargo-generate-rpm
run: cargo install cargo-generate-rpm
# Download the ubuntu artifact instead of rebuilding.
- name: Download artifacts
- name: Download linux artifacts
uses: actions/download-artifact@v6
with:
name: stableartifacts-ubuntu-24.04
- name: Build RPM
run: |
tar -xzvf floki*.tar.gz
mkdir -p target/release
cp floki target/release/floki
cargo generate-rpm
- name: Debug
run: |
set -ex

ls -ltR .
ls -l /usr/bin

name: dist-linux
path: dist-linux
- name: Install RPM
run: find . -name "floki*.rpm" | xargs sudo rpm -ivh
run: |
set -euxo pipefail
find dist-linux -name "floki*.rpm" -exec sudo rpm -ivh {} \;
- name: Test installation
run: floki -V
- name: Archive artifacts
uses: actions/upload-artifact@v5
with:
name: rpm
path: |
target/generate-rpm/floki*.rpm

publish:
name: Publish release artifact
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
needs:
- build
- rpm
# Required to publish a release
permissions:
contents: write
steps:
- uses: actions/checkout@v5
- name: Install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Install cargo-get
run: cargo install cargo-get
- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.PUBLISH_SECRET }}
# After publishing, create a release
- name: Download ubuntu artifacts
uses: actions/download-artifact@v6
with:
name: stableartifacts-ubuntu-24.04
- name: Download macos artifacts
uses: actions/download-artifact@v6
with:
name: stableartifacts-macos-latest
- name: Download RPM
uses: actions/download-artifact@v6
with:
name: rpm
- name: Generate release.txt
run: "./changelog.sh"
- name: Release
uses: softprops/action-gh-release@v2
with:
body_path: release.txt
files: |
floki*.zip
floki*.tar.gz
floki*.rpm
# # Announce the release
# - run: "./announce.sh"
# env:
# ANNOUNCE_HOOK: ${{ secrets.ANNOUNCE_HOOK }}

publish-dry-run:
name: Dry-run publish for non-release artifact
runs-on: ubuntu-latest
if: github.ref_type != 'tag'
needs:
- build
- rpm
steps:
- uses: actions/checkout@v5
- name: Install rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Install cargo-get
run: cargo install cargo-get
- name: Dry-run publish on non-tags
run: cargo publish --dry-run
# Test downloading the artifacts
- name: Download ubuntu artifacts
uses: actions/download-artifact@v6
with:
name: stableartifacts-ubuntu-24.04
- name: Download macos artifacts
uses: actions/download-artifact@v6
with:
name: stableartifacts-macos-latest
- name: Download rpm
uses: actions/download-artifact@v6
with:
name: rpm
# Test generating release.txt
- name: Generate release.txt
run: "./changelog.sh"
Loading