Skip to content

Commit

Permalink
[CI] Update Actions (#21)
Browse files Browse the repository at this point in the history
-  upgraded to checkout, upload-artifact, deploy-pages, and configure-pages
-  only publish `RelWithDebInfo` builds in artifact
- separated test into a dedicated action
- only send discord notification on failure
  • Loading branch information
hugsy authored Dec 15, 2023
1 parent 7f82f48 commit 49ae222
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 79 deletions.
50 changes: 21 additions & 29 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: "Build Artifact"
name: Build

on:
push:
pull_request:
push:
branches:
- main
schedule:
- cron: 0 0 * * *
workflow_dispatch:
Expand All @@ -12,15 +14,17 @@ on:
required: false
default: nightly

env:
CMAKE_FLAGS: "-DCFB_BUILD_TOOLS:BOOL=ON -DCFB_BUILD_TESTS:BOOL=ON -DCFB_BUILD_GUI:BOOL=ON"
CMAKE_TOOLCHAIN_FILE: "C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake"
TAG_NAME: ""

jobs:
build:
name: "${{ matrix.platform }}/${{ matrix.configuration }}"

env:
CMAKE_FLAGS: "-DCFB_BUILD_TOOLS:BOOL=ON -DCFB_BUILD_GUI:BOOL=ON -DCFB_BUILD_TESTS:BOOL=OFF"
CMAKE_TOOLCHAIN_FILE: "C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake"
TAG_NAME: ""
NB_CPU: 1

strategy:
fail-fast: false
matrix:
Expand All @@ -30,52 +34,40 @@ jobs:

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Checkout
uses: actions/checkout@v4

- if: github.event_name == 'workflow_dispatch'
run: echo "TAG_NAME=${{ github.event.inputs.tag_name }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

- if: github.event_name == 'schedule'
run: echo "TAG_NAME=nightly" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

- name: Prepare
shell: pwsh
run: |
echo "NB_CPU=$env:NUMBER_OF_PROCESSORS" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
mkdir artifact
mkdir build

- name: Setup
shell: pwsh
run: |
echo "NB_CPU=$env:NUMBER_OF_PROCESSORS" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Import-Module .\.github\Invoke-VisualStudio.ps1
Invoke-VisualStudio2022${{ matrix.platform }}
- name: Build
shell: pwsh
run: |
mkdir build
cmake -S . -B ./build -A ${{ matrix.platform }} ${{ env.CMAKE_FLAGS }}
cmake --build ./build --verbose --parallel ${{ env.NB_CPU }} --config ${{ matrix.configuration }}
- name: Test
continue-on-error: true
shell: pwsh
run: |
cd build
ctest --parallel ${{ env.NB_CPU }} --build-config ${{ matrix.configuration }} -T test
cd ..
- name: Install
shell: pwsh
if: matrix.configuration == 'RelWithDebInfo'
run: |
mkdir artifact
cmake --install ./build --config ${{ matrix.configuration }} --prefix ./artifact --verbose
- name: Upload
uses: actions/upload-artifact@v3
if: matrix.configuration == 'RelWithDebInfo'
with:
name: CFB_${{ matrix.platform }}_${{ matrix.configuration }}_${{ github.sha }}
name: CFB_${{ matrix.platform }}_${{ matrix.configuration }}_${{ github.head_ref }}_${{ github.sha }}
path: artifact/
retention-days: 1

13 changes: 6 additions & 7 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: Generate Docs

on:
workflow_dispatch:

push:
branches: ["dev"]
branches:
- main

permissions:
contents: read
Expand All @@ -23,13 +22,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v2
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v2
with:
path: './Docs'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v2
68 changes: 25 additions & 43 deletions .github/workflows/notify.yml
Original file line number Diff line number Diff line change
@@ -1,94 +1,76 @@
name: "Discord Notification"
name: Notify

on:
pull_request:
types: [ opened ]
issues:
types: [ opened ]
workflow_run:
workflows: ["Build Artifact", "build"]
workflows: ["Build", "Test"]
types: [completed]
branches: ["*"]

permissions:
contents: read

env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}

jobs:
on-success:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: CI Build Success Notification
uses: sarisia/actions-status-discord@v1
with:
nodetail: true
title: "[${{ github.repository }}] ${{ github.actor }} pushed to `${{ github.ref }}`"
description: |
**Commits**:
● ${{ join(github.event.commits.*.message, '
● ') }}
---
**Link**: ${{ github.event.compare }}
color: 0x0000ff
username: ${{ github.actor }} on CFB
avatar_url: https://i.imgur.com/O4RKNqj.png

on-failure:
on_workflow_failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- name: CI Build Failure Notification
if: ${{ github.event.workflow_run.conclusion == 'success' }}
uses: sarisia/actions-status-discord@v1
- uses: sarisia/actions-status-discord@v1
with:
nodetail: true
title: "[${{ github.repository }}] ${{ github.actor }} pushed to `${{ github.ref }}`"
title: "⚠️ '${{ github.event.workflow_run.name }}' failed ${{ github.sha }} on ${{ github.ref }} ${{ github.actor }}"
description: |
**Commits**:
● ${{ join(github.event.commits.*.message, '
● ') }}
Build failure for
● SHA ${{ github.sha }}
● REF ${{ github.ref }}
● ACTOR ${{ github.actor }}
---
**Link**: ${{ github.event.compare }}
[Link](${{ github.event.workflow_run.html_url }})
color: 0xff0000
username: ${{ github.actor }} on CFB
avatar_url: https://i.imgur.com/O4RKNqj.png

on-pull-requests:
on_pull_requests:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Triggering Pull Request Discord Notification
if: github.event_name == 'pull_request' && github.event.action == 'opened' && github.repository_owner == 'hugsy'
uses: sarisia/actions-status-discord@v1
- uses: sarisia/actions-status-discord@v1
with:
nodetail: true
title: ${{ github.actor }} created a new Pull Request (`#${{ github.event.pull_request.number }}`)
title: "🚧 ${{ github.actor }} ${{ github.event.action }} PR `#${{ github.event.pull_request.number }}`"
description: |
**${{ github.event.pull_request.title }}**
${{ github.event.pull_request.body }}
---
Link: ${{ github.event.pull_request.html_url }}
color: 0xff0000
[Link](${{ github.event.pull_request.html_url }})
color: 0x00ff00
username: ${{ github.actor }} on CFB
avatar_url: https://i.imgur.com/O4RKNqj.png

on-issues:
runs-on: ubuntu-latest
if: github.event_name == 'issues'
steps:
- name: Triggering Issue Discord Notification
if: github.event_name == 'issues' && github.event.action == 'opened' && github.repository_owner == 'hugsy'
uses: sarisia/actions-status-discord@v1
- uses: sarisia/actions-status-discord@v1
with:
nodetail: true
title: ${{ github.actor }} created a new Issue (`#${{ github.event.issue.number }}`)
title: "${{ github.actor }} ${{ github.event.action }} Issue `#${{ github.event.issue.number }}`"
description: |
**${{ github.event.issue.title }}**
${{ github.event.issue.body }}
---
Link: ${{ github.event.issue.html_url }}
color: 0x00ff00
[Link](${{ github.event.issue.html_url }})
color: 0x0000ff
username: ${{ github.actor }} on CFB
avatar_url: https://i.imgur.com/O4RKNqj.png
46 changes: 46 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Test

on:
workflow_run:
workflows: ["Build",]

jobs:
test:
name: "${{ matrix.platform }}/${{ matrix.configuration }}"

env:
CMAKE_FLAGS: "-DCFB_BUILD_TOOLS:BOOL=OFF -DCFB_BUILD_GUI:BOOL=OFF -DCFB_BUILD_TESTS:BOOL=ON"
CMAKE_TOOLCHAIN_FILE: "C:\\vcpkg\\scripts\\buildsystems\\vcpkg.cmake"
TAG_NAME: ""
NB_CPU: 1

strategy:
fail-fast: false
matrix:
os: ['windows-latest']
platform: ['x64'] # , 'arm64', 'win32'
configuration: ['RelWithDebInfo'] # 'Debug',

runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup
shell: pwsh
run: |
echo "NB_CPU=$env:NUMBER_OF_PROCESSORS" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Import-Module .\.github\Invoke-VisualStudio.ps1
Invoke-VisualStudio2022${{ matrix.platform }}
- name: Build
shell: pwsh
run: |
mkdir build
cmake -S . -B ./build -A ${{ matrix.platform }} ${{ env.CMAKE_FLAGS }}
cmake --build ./build --verbose --parallel ${{ env.NB_CPU }} --config ${{ matrix.configuration }}
- name: Test
shell: pwsh
run: |
ctest --parallel ${{ env.NB_CPU }} --build-config ${{ matrix.configuration }} -T test --test-dir ./build

0 comments on commit 49ae222

Please sign in to comment.