Skip to content

Commit

Permalink
ci: add GitHub workflows
Browse files Browse the repository at this point in the history
We port over most of the GitLab pipelines to GitHub Actions. Missing is the
coverage reporting for now.

On the other side we add a package build step. This will allow CI consumers of
Disman to directly install from this package when using Disman from master.
  • Loading branch information
romangg committed Feb 19, 2024
1 parent c626fbd commit ec22177
Show file tree
Hide file tree
Showing 10 changed files with 425 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/actions/dep-artifact-generic/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# SPDX-FileCopyrightText: 2024 Roman Gilg <[email protected]>
# SPDX-License-Identifier: MIT
name: Install Dependency via Artifact
description: Uses tar package from other workflow to install on Arch
inputs:
repo:
description: Path to repo where to download the dependency from
required: true
branch:
description: Branch from which to download the artifact
required: false
default: master
dep-name:
description: Name of the dependency file
required: true
secret:
description: Secret
required: true
runs:
using: "composite"
steps:
- name: Download artifact
uses: dawidd6/action-download-artifact@v3
with:
name: tar-package
repo: ${{ inputs.repo }}
branch: ${{ inputs.branch }}
workflow_search: true
github_token: ${{ inputs.secret }}
- name: Untar
run: tar -xf ${{ inputs.dep-name }}.tar.gz
shell: bash
- name: Install
run: cp -r ${{ inputs.dep-name }}/* /usr
shell: bash
17 changes: 17 additions & 0 deletions .github/actions/dep-artifacts/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SPDX-FileCopyrightText: 2024 Roman Gilg <[email protected]>
# SPDX-License-Identifier: MIT
name: Specialized Install Dependency via Artifact
description: Calls into more generic dep-artifact-generic to install dependency
inputs:
secret:
description: Secret
required: true
runs:
using: "composite"
steps:
- name: Install Wrapland
uses: ./.github/actions/dep-artifact-generic
with:
repo: winft/wrapland
dep-name: wrapland
secret: ${{ inputs.secret }}
87 changes: 87 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# SPDX-FileCopyrightText: 2024 Roman Gilg <[email protected]>
# SPDX-License-Identifier: MIT
name: Build
on:
workflow_call:
inputs:
image:
description: Image to build
required: true
type: string
artifact-name:
description: Artifact name of build dir
required: false
type: string
default: 'build'
is-sanitized:
description: Should sanitizers be compiled into the build
required: false
type: boolean
default: false
ninja:
description: Should Ninja be used as generator
required: false
type: boolean
default: true
cmake-args:
description: Specify CMake arguments manually
required: false
type: string
default: ''
jobs:
set-cmake-args:
name: CMake Args
runs-on: ubuntu-latest
env:
cmake-args: ''
outputs:
args: ${{ steps.set-output.outputs.result }}
steps:
- name: Set from manually specified CMake args
if: ${{ inputs.cmake-args != '' }}
run: echo \"cmake-args=${{ inputs.cmake-args }}\" >> $GITHUB_ENV;
- name: Set default CMake args for sanitized build
if: ${{ inputs.cmake-args == '' && inputs.is-sanitized }}
run: echo "cmake-args=-DECM_ENABLE_SANITIZERS='address;leak;undefined'" >> $GITHUB_ENV"
- name: Set default CMake args for coverage build
if: ${{ inputs.cmake-args == '' && !inputs.is-sanitized }}
run:
"echo \"cmake-args=-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_CXX_FLAGS=--coverage -DCMAKE_EXE_LINKER_FLAGS=--coverage\" >> $GITHUB_ENV"
- name: Set clang as compiler
if: ${{ inputs.cmake-args == '' }}
run:
"echo \"cmake-args=-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
${{ env.cmake-args }}\" >> $GITHUB_ENV"
- name: Set generator
if: ${{ inputs.cmake-args == '' && inputs.ninja }}
run: echo "cmake-args=-G Ninja ${{ env.cmake-args }}" >> $GITHUB_ENV
- id: set-output
name: Set resulting variable
run: echo "result=${{ env.cmake-args }}" >> "$GITHUB_OUTPUT"
build:
name: Build
needs: set-cmake-args
runs-on: ubuntu-latest
container:
image: ${{ inputs.image }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Install Dependencies
uses: ./.github/actions/dep-artifacts
with:
secret: ${{ secrets.GITHUB_TOKEN }}
- run: mkdir build
- name: Configure
run: cmake -S . -B build ${{ needs.set-cmake-args.outputs.args }}
- name: Build
run: cmake --build build
- name: Tar artifact (keep permissions)
run: tar -czf build-dir.tar build
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: build-dir.tar
retention-days: 1
38 changes: 38 additions & 0 deletions .github/workflows/change.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SPDX-FileCopyrightText: 2024 Roman Gilg <[email protected]>
# SPDX-License-Identifier: MIT
name: Main Checks
on:
- push
- pull_request
jobs:
message-lint:
uses: ./.github/workflows/commit-lint.yml
with:
upstream-repo: winft/disman

clang-format:
uses: ./.github/workflows/clang-format.yml

build:
uses: ./.github/workflows/build.yml
with:
image: registry.gitlab.com/kwinft/ci-images/archlinux/frameworks-master

install:
uses: ./.github/workflows/install.yml
needs: build
with:
image: registry.gitlab.com/kwinft/ci-images/archlinux/frameworks-master

test:
uses: ./.github/workflows/test.yml
needs: build
with:
image: registry.gitlab.com/kwinft/ci-images/archlinux/frameworks-master

package:
uses: ./.github/workflows/package.yml
needs: build
with:
image: registry.gitlab.com/kwinft/ci-images/archlinux/frameworks-master
package-name: disman
15 changes: 15 additions & 0 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# SPDX-FileCopyrightText: 2024 Roman Gilg <[email protected]>
# SPDX-License-Identifier: MIT
name: Clang-Format
on: workflow_call
jobs:
clang-format:
name: Clang-Format
runs-on: ubuntu-latest
container:
image: archlinux
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- run: pacman -Sy --needed --quiet --noconfirm clang python
- run: bash tooling/analysis/clang-format.sh
55 changes: 55 additions & 0 deletions .github/workflows/commit-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# SPDX-FileCopyrightText: 2024 Roman Gilg <[email protected]>
# SPDX-License-Identifier: MIT
name: Commit Message Lint
on:
workflow_call:
inputs:
upstream-repo:
description: 'The repo with the target branch to compare against'
required: true
type: string
upstream-branch:
description: 'The target branch we compare against'
required: false
type: string
default: 'master'
env:
upstream-repo-url: https://github.com/${{ inputs.upstream-repo }}
jobs:
message-lint:
if: github.event_name != 'pull_request'
name: On Push
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Add Commitlint CLI
run: yarn global add @commitlint/cli
- name: Add Conventional Changelog module
run: yarn add conventional-changelog-conventionalcommits

# We must unshallow the checkout. On GitHub it's by default only 1 commit deep.
- name: Unshallow
run: git fetch --unshallow origin ${{ github.head_ref || github.ref_name }}

- name: Add upstream remote
run: git remote add _upstream ${{ env.upstream-repo-url }}
- name: Fetch upstream
run: git fetch --depth=1 -q _upstream ${{ inputs.upstream-branch }}
- name: Commitlint
run: >
commitlint --verbose --config=tooling/docs/commitlint.config.js
--from=_upstream/${{ inputs.upstream-branch }}
message-lint-pr:
if: github.event_name == 'pull_request'
name: On Pull Request
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- uses: wagoid/commitlint-github-action@v5
with:
configFile: tooling/docs/commitlint.config.js
helpURL: https://github.com/${{ inputs.upstream-repo }}/blob/master/CONTRIBUTING.md#commit-message-guideline
32 changes: 32 additions & 0 deletions .github/workflows/install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# SPDX-FileCopyrightText: 2024 Roman Gilg <[email protected]>
# SPDX-License-Identifier: MIT
name: Build
on:
workflow_call:
inputs:
image:
description: Image to build
required: true
type: string
artifact-name:
description: Artifact name of build dir
required: false
type: string
default: 'build'
jobs:
install:
name: Install
runs-on: ubuntu-latest
container:
image: ${{ inputs.image }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact-name }}
- name: Untar artifact
run: tar -xzf build-dir.tar
- name: Try Install to System
run: cmake --install build
70 changes: 70 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# SPDX-FileCopyrightText: 2024 Roman Gilg <[email protected]>
# SPDX-License-Identifier: MIT
name: Package
on:
workflow_call:
inputs:
image:
description: Image to package on
required: true
type: string
artifact-name:
description: Artifact name of build dir
required: false
type: string
default: 'build'
package-name:
description: Name of the resulting packages
required: true
type: string

jobs:
deb:
name: Create deb
runs-on: ubuntu-latest
container:
image: ${{ inputs.image }}
steps:
- name: Install dpkg
run: pacman -Sy --needed --quiet --noconfirm dpkg
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact-name }}
- name: Untar artifact
run: tar -xzf build-dir.tar
- name: Run CPack
run: cd build && cpack -G DEB -D CPACK_DEBIAN_FILE_NAME=${{ inputs.package-name }}.deb
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: deb-package
path: build/_CPack_Packages/Linux/DEB/${{ inputs.package-name }}.deb
retention-days: 8

tar:
name: Create tar
runs-on: ubuntu-latest
container:
image: ${{ inputs.image }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact-name }}
- name: Untar artifact
run: tar -xzf build-dir.tar
- name: Run CPack
# Need to use CPACK_PACKAGE_FILE_NAME instead of CPACK_ARCHIVE_FILE_NAME
# See: https://gitlab.kitware.com/cmake/cmake/-/issues/20419
run: cd build && cpack -G TGZ -D CPACK_PACKAGE_FILE_NAME=${{ inputs.package-name }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: tar-package
path: build/_CPack_Packages/Linux/TGZ/${{ inputs.package-name }}.tar.gz
retention-days: 8
19 changes: 19 additions & 0 deletions .github/workflows/rebuild.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-FileCopyrightText: 2024 Roman Gilg <[email protected]>
# SPDX-License-Identifier: MIT
name: Weekly Project Rebuild
on:
schedule:
- cron: '0 4 * * 4'
jobs:
build:
if: github.repository == 'winft/disman'
uses: ./.github/workflows/build.yml
with:
image: registry.gitlab.com/kwinft/ci-images/archlinux/frameworks-master

package:
uses: ./.github/workflows/package.yml
needs: build
with:
image: registry.gitlab.com/kwinft/ci-images/archlinux/frameworks-master
package-name: disman
Loading

0 comments on commit ec22177

Please sign in to comment.