Skip to content

CI by Jo5ta

CI by Jo5ta #46

Workflow file for this run

name: CI Pipeline
run-name: CI by ${{ github.actor }}
on:
push:
branches: ['main']
pull_request:
branches: ['main']
env:
CI: true
CONTAINER_TARGET: ci
CONTAINER_CMD: docker
CONTAINER_NON_INTERACTIVE: true
# Required for pushing to ghcr.io and creating releases
permissions:
contents: write
packages: write
jobs:
# ============================================
# Quick checks (format, version) - fail fast
# ============================================
checks:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Load CI-Container
uses: ./.github/actions/load-container
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Format Check
run: ./scripts/container.sh ./scripts/ci-cd/step_format.sh
- name: Fetch main branch for version check
if: github.event_name == 'pull_request'
run: git fetch origin main:main
- name: Version Check
if: github.event_name == 'pull_request'
run: ./scripts/container.sh ./scripts/ci-cd/step_version.sh
# ============================================
# Build and Test
# ============================================
build-and-test:
runs-on: ubuntu-latest
needs: checks
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup ccache
run: mkdir -p ~/.ccache
- name: Restore ccache
uses: actions/cache@v4
with:
path: ~/.ccache
key: ccache-${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}-${{ github.sha }}
restore-keys: |
ccache-${{ runner.os }}-build-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}-
ccache-${{ runner.os }}-build-
- name: Load CI-Container
uses: ./.github/actions/load-container
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Build
run: ./scripts/container.sh ./scripts/ci-cd/step_build.sh
- name: Show ccache stats
run: ./scripts/container.sh ccache --show-stats || true
- name: Test
run: ./scripts/container.sh ./scripts/ci-cd/step_test.sh
- name: Memory Check
run: ./scripts/container.sh ./scripts/ci-cd/step_memcheck.sh
# ============================================
# Packaging
# ============================================
package:
runs-on: ubuntu-latest
needs: build-and-test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup ccache
run: mkdir -p ~/.ccache
- name: Restore ccache
uses: actions/cache@v4
with:
path: ~/.ccache
key: ccache-${{ runner.os }}-package-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}-${{ github.sha }}
restore-keys: |
ccache-${{ runner.os }}-package-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}-
ccache-${{ runner.os }}-package-
ccache-${{ runner.os }}-build-
- name: Load CI-Container
uses: ./.github/actions/load-container
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Package
run: ./scripts/container.sh ./scripts/ci-cd/step_package.sh
- name: Show ccache stats
run: ./scripts/container.sh ccache --show-stats || true
- name: Package Validate
run: ./scripts/container.sh ./scripts/ci-cd/step_package_validate.sh --skip-srpm-rebuild
# ==========================================
# Create GitHub Release (only on push to main)
# ==========================================
- name: Get version and generate release info
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
id: release_info
env:
COMMIT_SHA: ${{ github.sha }}
run: |
set -e
VERSION=$(head -n1 VERSION.md)
echo "version=$VERSION" >> $GITHUB_OUTPUT
# Create a unique tag using version + short commit hash
SHORT_SHA=$(echo "$COMMIT_SHA" | cut -c1-7)
echo "tag=v${VERSION}-${SHORT_SHA}" >> $GITHUB_OUTPUT
# Find packages directory (container.sh puts it under build/in_container/*/build/packages)
PACKAGES_DIR=$(find build -type d -name packages | head -1)
if [ -z "$PACKAGES_DIR" ]; then
echo "ERROR: No packages directory found"
exit 1
fi
# Check that SRPM exists
if ! ls "$PACKAGES_DIR"/*.src.rpm 1>/dev/null 2>&1; then
echo "ERROR: No SRPM found in $PACKAGES_DIR"
exit 1
fi
# Copy SRPM to current directory and generate checksums there
# (packages dir may be owned by root from container)
cp "$PACKAGES_DIR"/*.src.rpm .
sha256sum *.src.rpm > SHA256SUMS
# Build release body with checksums embedded
{
echo "Release of Common Low Level Tracing Kit"
echo ""
echo "**Commit:** ${COMMIT_SHA}"
echo ""
echo "## Install from SRPM"
echo "\`\`\`bash"
echo "rpmbuild --rebuild clltk-${VERSION}-*.src.rpm"
echo "sudo dnf install ~/rpmbuild/RPMS/x86_64/clltk-*.rpm"
echo "\`\`\`"
echo ""
echo "## Checksums (SHA256)"
echo "\`\`\`"
cat SHA256SUMS
echo "\`\`\`"
} > release_body.md
- name: Create Release
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.release_info.outputs.tag }}
name: ${{ steps.release_info.outputs.version }}
body_path: release_body.md
files: |
*.src.rpm
SHA256SUMS