diff --git a/.github/actions/dep-artifact-generic/action.yml b/.github/actions/dep-artifact-generic/action.yml new file mode 100644 index 0000000..b242702 --- /dev/null +++ b/.github/actions/dep-artifact-generic/action.yml @@ -0,0 +1,35 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# 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 diff --git a/.github/actions/dep-artifacts/action.yml b/.github/actions/dep-artifacts/action.yml new file mode 100644 index 0000000..f41d066 --- /dev/null +++ b/.github/actions/dep-artifacts/action.yml @@ -0,0 +1,17 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# 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 }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..4f16025 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,87 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# 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 diff --git a/.github/workflows/change.yml b/.github/workflows/change.yml new file mode 100644 index 0000000..9b5fdb4 --- /dev/null +++ b/.github/workflows/change.yml @@ -0,0 +1,38 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# 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 diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml new file mode 100644 index 0000000..b18a61b --- /dev/null +++ b/.github/workflows/clang-format.yml @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# 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 diff --git a/.github/workflows/commit-lint.yml b/.github/workflows/commit-lint.yml new file mode 100644 index 0000000..b519ee0 --- /dev/null +++ b/.github/workflows/commit-lint.yml @@ -0,0 +1,55 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# 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 diff --git a/.github/workflows/install.yml b/.github/workflows/install.yml new file mode 100644 index 0000000..fa50a40 --- /dev/null +++ b/.github/workflows/install.yml @@ -0,0 +1,32 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# 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 diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml new file mode 100644 index 0000000..adfc137 --- /dev/null +++ b/.github/workflows/package.yml @@ -0,0 +1,70 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# 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 diff --git a/.github/workflows/rebuild.yml b/.github/workflows/rebuild.yml new file mode 100644 index 0000000..7a89e71 --- /dev/null +++ b/.github/workflows/rebuild.yml @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# 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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..67b13cf --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,57 @@ +# SPDX-FileCopyrightText: 2024 Roman Gilg +# SPDX-License-Identifier: MIT +name: Test +on: + workflow_call: + inputs: + image: + description: Image to run tests on + required: true + type: string + artifact-name: + description: Artifact name of build dir + required: false + type: string + default: 'build' + ctest-args: + description: Specify additional CTest arguments + required: false + type: string + default: '' + +jobs: + test: + name: Test + 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 }} + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.artifact-name }} + - name: Untar artifact + run: tar -xzf build-dir.tar + - name: List all tests + run: ctest --test-dir build -N + # Tests currently only run in one thread. + - name: Run selected tests + env: + DISPLAY: ":1" + WAYLAND_DEBUG: "server" + MESA_DEBUG: "1" + LIBGL_DEBUG: "verbose" + QT_LOGGING_RULES: "*=true" + ASAN_OPTIONS: "detect_odr_violation=0" + run: + "Xvfb :1 -ac -screen 0 1920x1080x24 > /dev/null 2>&1 & + + dbus-run-session ctest --test-dir build -T Test \ + --output-on-failure --no-compress-output ${{ inputs.ctest-args }}" + shell: bash