Skip to content

Extend server configuration with compression config #18

Extend server configuration with compression config

Extend server configuration with compression config #18

Workflow file for this run

# TODO:
# - generate shasum for each published zip, include it in metadata.yaml and in the release description
# - consider stripping debug symbols from binaries
# - optimize workflow to avoid having almost same matrix twice
# - avoid building with debug and release after - it should be better to build release only and test it
# - generate RELEASE.md changelog
# - change ubuntu to alpine in Dockerfile.ci and Dockerfile
# - merge Docker meta into one step
# - implement cargo-semver-checks
name: CI
on:
pull_request:
branches:
- master
types: [opened, synchronize, reopened, closed]
env:
CRATE_NAME: iggy
GITHUB_TOKEN: ${{ github.token }}
RUST_BACKTRACE: 1
CARGO_TERM_COLOR: always
DOCKERHUB_REGISTRY_NAME: iggyrs/iggy
IGGY_CI_BUILD: true
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
sanity:
uses: ./.github/workflows/sanity.yml
build_and_test:
needs: sanity
name: ${{ matrix.platform.skip_tests == true && 'build' || 'build and test' }} ${{ matrix.platform.os_name }}
runs-on: ${{ matrix.platform.os }}
timeout-minutes: 45
strategy:
fail-fast: false
matrix:
platform:
- os_name: Linux-x86_64-musl
os: ubuntu-latest
target: x86_64-unknown-linux-musl
bin:
- iggy-server
- iggy-cli
name: iggy-Linux-x86_64-musl.tar.gz
cargo_command: cargo
docker_arch: linux/amd64
cross: false
- os_name: Linux-arm
os: ubuntu-22.04
target: arm-unknown-linux-musleabi
bin:
- iggy-server
- iggy-cli
name: iggy-Linux-arm-musl.tar.gz
docker_arch: linux/arm/v7
cross: true
qemu_runner: "qemu-arm"
- os_name: Linux-aarch64-musl
os: ubuntu-latest
target: aarch64-unknown-linux-musl
bin:
- iggy-server
- iggy-cli
name: iggy-Linux-aarch64-musl.tar.gz
docker_arch: linux/arm64/v8
cross: true
qemu_runner: "qemu-aarch64"
- os_name: macOS-aarch64
os: macOS-latest
target: aarch64-apple-darwin
bin:
- iggy-server
- iggy-cli
name: iggy-Darwin-aarch64.tar.gz
skip_tests: true
cross: false
- os_name: Windows-x86_64
os: windows-latest
target: x86_64-pc-windows-msvc
bin:
- iggy-server
- iggy-cli
name: iggy-Windows-x86_64.zip
skip_tests: true
cross: false
toolchain:
- stable
# - nightly
# - beta
steps:
- uses: actions/checkout@v3
- name: Cache cargo & target directories
uses: Swatinem/rust-cache@v2
with:
key: "v2"
- name: Configure Git
run: |
git config --global user.email "[email protected]"
git config --global user.name "J. Doe"
- name: Set environment variables
run: export QEMU_RUNNER=${{ matrix.platform.qemu_runner }}
if: ${{ matrix.platform.cross }}
- name: Install musl-tools on Linux
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools
if: contains(matrix.platform.name, 'musl')
- name: Build binary
uses: houseabsolute/actions-rust-cross@v0
with:
command: "build"
target: ${{ matrix.platform.target }}
toolchain: ${{ matrix.toolchain }}
args: "--verbose"
- name: Run tests
uses: houseabsolute/actions-rust-cross@v0
with:
command: "test"
target: ${{ matrix.platform.target }}
toolchain: ${{ matrix.toolchain }}
args: "--verbose"
if: ${{ !matrix.platform.skip_tests }}
- name: Check if workspace is clean
run: git status | grep "working tree clean" || { git status ; exit 1; }
if: runner.os != 'Windows'
if_merged:
needs: build_and_test
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- run: |
echo The PR was merged
coverage:
needs: if_merged
uses: ./.github/workflows/coverage.yml
tag:
runs-on: ubuntu-latest
needs: if_merged
if: |
${{ github.ref }} == 'refs/heads/master' || ${{ github.ref }} == 'refs/heads/test_release_branch'
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check if Cargo.toml and Cargo.lock are changed
uses: tj-actions/changed-files@v39
id: all_changed_files
with:
files: |
Cargo.lock
server/Cargo.toml
- name: Extract iggy-server version from Cargo.toml
if: ${{ steps.all_changed_files.outputs.all_changed_files == 'Cargo.lock server/Cargo.toml' }}
id: extract_version
run: |
version=$(cargo pkgid -p server | cut -d# -f2 | cut -d: -f2)
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "::notice ::Version from Cargo.toml $version"
- name: Check if version is a Git tag
uses: mukunku/[email protected]
if: ${{ steps.all_changed_files.outputs.all_changed_files == 'Cargo.lock server/Cargo.toml' }}
id: check_git_tag
with:
tag: "${{ steps.extract_version.outputs.version }}"
- name: Print message
if: ${{ steps.check_git_tag.outputs.exists == 'true' }}
run: |
echo "::notice ::Tag ${{ steps.extract_version.outputs.version }} exists, skipping tag creation"
- name: Create tag
if: ${{ steps.check_git_tag.outputs.exists == 'false' }}
id: tagging
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git tag -a ${{ steps.extract_version.outputs.version }} -m "${{ steps.extract_version.outputs.version }}"
git push origin ${{ steps.extract_version.outputs.version }}
echo "::notice ::Created ${{ steps.extract_version.outputs.version }} tag"
echo "tag_created=true" >> "$GITHUB_OUTPUT"
- name: Get Repository Name
id: repository
run: echo "name=${GITHUB_REPOSITORY#*/}" >> $GITHUB_OUTPUT
outputs:
version: ${{ steps.extract_version.outputs.version }}
tag_created: ${{ steps.tagging.outputs.tag_created }}
release_and_publish:
name: build release ${{ matrix.platform.os_name }}
needs: tag
runs-on: ${{ matrix.platform.os }}
strategy:
matrix:
platform:
- os_name: Linux-x86_64-musl
os: ubuntu-latest
target: x86_64-unknown-linux-musl
bin:
- iggy-server
- iggy-cli
name: iggy-Linux-x86_64-musl.tar.gz
cargo_command: cargo
docker_arch: linux/amd64
cross: false
- os_name: Linux-arm
os: ubuntu-22.04
target: arm-unknown-linux-musleabi
bin:
- iggy-server
- iggy-cli
name: iggy-Linux-arm-musl.tar.gz
docker_arch: linux/arm/v7
cross: true
qemu_runner: "qemu-arm"
- os_name: Linux-aarch64-musl
os: ubuntu-latest
target: aarch64-unknown-linux-musl
bin:
- iggy-server
- iggy-cli
name: iggy-Linux-aarch64-musl.tar.gz
docker_arch: linux/arm64/v8
cross: true
qemu_runner: "qemu-aarch64"
# skip release for MacOs-darwin-aarch64 and Widows/amd64
# people don't use them for servers
# - os_name: macOS-aarch64
# os: macOS-latest
# target: aarch64-apple-darwin
# bin:
# - iggy-server
# - iggy-cli
# name: iggy-Darwin-aarch64.tar.gz
# docker_arch: darwin/a arch64
# cross: false
# - os_name: Windows-x86_64
# os: windows-latest
# target: x86_64-pc-windows-msvc
# bin:
# - iggy-server
# - iggy-cli
# name: iggy-Windows-x86_64.zip
# docker_arch: windows/amd64
# cross: false
toolchain:
- stable
outputs:
version: ${{ needs.tag.outputs.version }}
tag_created: ${{ needs.tag.outputs.tag_created }}
steps:
- uses: actions/checkout@v3
- name: Cache cargo & target directories
uses: Swatinem/rust-cache@v2
with:
key: "v2"
- name: Set environment variables
run: export QEMU_RUNNER=${{ matrix.platform.qemu_runner }}
if: ${{ matrix.platform.cross }}
- name: Install musl-tools on Linux
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools
if: contains(matrix.platform.name, 'musl')
- name: Build release binary
uses: houseabsolute/actions-rust-cross@v0
with:
command: "build"
target: ${{ matrix.platform.target }}
toolchain: ${{ matrix.toolchain }}
args: "--verbose --release"
if: ${{ matrix.toolchain }} == 'stable'
- name: Prepare artifacts
run: |
mkdir -p release_artifacts/
cp target/${{ matrix.platform.target }}/release/iggy-server release_artifacts/
cp target/${{ matrix.platform.target }}/release/iggy-cli release_artifacts/
- name: Release artifacts archive on GitHub
uses: actions/upload-artifact@v3
with:
name: iggy-${{ matrix.platform.os_name }}
path: release_artifacts/
- name: Print message
run: echo "::notice ::Published ${{ needs.tag.outputs.version }} release artifacts on GitHub"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
with:
platforms: "arm64,arm"
if: ${{ matrix.platform.cross }}
- name: Set up Docker
uses: crazy-max/ghaction-setup-docker@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKERHUB_REGISTRY_NAME }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v4
with:
context: ./
file: ./Dockerfile.ci
platforms: ${{ matrix.platform.docker_arch }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.DOCKERHUB_REGISTRY_NAME }},push-by-digest=true,name-canonical=true,push=true
build-args: |
IGGY_CLI_PATH=target/${{ matrix.platform.target }}/release/iggy-cli
IGGY_SERVER_PATH=target/${{ matrix.platform.target }}/release/iggy-server
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v3
with:
name: digests
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge_docker_manifest:
runs-on: ubuntu-latest
needs:
- release_and_publish
- tag
steps:
- name: Download digests
uses: actions/download-artifact@v3
with:
name: digests
path: /tmp/digests
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker meta (tag was created)
if: ${{ needs.tag.outputs.tag_created == 'true' }}
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKERHUB_REGISTRY_NAME }}
tags: |
${{ needs.tag.outputs.version }}
latest
- name: Docker meta (tag was not created)
if: ${{ needs.tag.outputs.tag_created == '' }}
uses: docker/metadata-action@v4
with:
images: ${{ env.DOCKERHUB_REGISTRY_NAME }}
tags: |
latest
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.DOCKERHUB_REGISTRY_NAME }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.DOCKERHUB_REGISTRY_NAME }}:latest