From 0d782aacdc7e443181426e042ef17954b2fb83ec Mon Sep 17 00:00:00 2001 From: Bryan Hundven Date: Mon, 11 Mar 2024 15:29:03 -0700 Subject: [PATCH] DRY github workflow Make install deps, build, and install actions re-usable. Signed-off-by: Bryan Hundven --- .github/actions/build_thinkfan/action.yaml | 12 ++++++++++++ .github/actions/install_thinkfan/action.yaml | 10 ++++++++++ .github/actions/install_thinkfan_deps/action.yaml | 11 +++++++++++ .github/workflows/ccpp.yml | 14 ++++---------- .github/workflows/codeql.yml | 12 +++--------- 5 files changed, 40 insertions(+), 19 deletions(-) create mode 100644 .github/actions/build_thinkfan/action.yaml create mode 100644 .github/actions/install_thinkfan/action.yaml create mode 100644 .github/actions/install_thinkfan_deps/action.yaml diff --git a/.github/actions/build_thinkfan/action.yaml b/.github/actions/build_thinkfan/action.yaml new file mode 100644 index 0000000..be6b47c --- /dev/null +++ b/.github/actions/build_thinkfan/action.yaml @@ -0,0 +1,12 @@ +name: Build thinkfan +description: 'Composite action to build thinkfan.' + +runs: + using: composite + steps: + - name: build + run: | + mkdir build + cmake -B build + cmake --build build + shell: bash diff --git a/.github/actions/install_thinkfan/action.yaml b/.github/actions/install_thinkfan/action.yaml new file mode 100644 index 0000000..4bf530e --- /dev/null +++ b/.github/actions/install_thinkfan/action.yaml @@ -0,0 +1,10 @@ +name: Install thinkfan +description: 'Composite action to install thinkfan.' + +runs: + using: composite + steps: + - name: install + run: | + sudo cmake --install ${{ github.workspace }}/build + shell: bash diff --git a/.github/actions/install_thinkfan_deps/action.yaml b/.github/actions/install_thinkfan_deps/action.yaml new file mode 100644 index 0000000..4bab678 --- /dev/null +++ b/.github/actions/install_thinkfan_deps/action.yaml @@ -0,0 +1,11 @@ +name: Install thinkfan Dependencies +description: 'Composite action to install thinkfan dependencies.' + +runs: + using: composite + steps: + - name: install-deps + run: | + sudo apt update + sudo apt install -y libyaml-cpp-dev libatasmart-dev cmake libsensors4-dev + shell: bash diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index a1645e4..8113d29 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -13,13 +13,7 @@ jobs: matrix: os: [ubuntu-20.04, ubuntu-22.04] steps: - - uses: actions/checkout@v2 - - name: install-deps - run: sudo apt install libyaml-cpp-dev libatasmart-dev cmake libsensors4-dev - - name: build - run: | - mkdir build - cmake -B build - cmake --build build - - name: install - run: sudo cmake --install ${{ github.workspace }}/build + - uses: actions/checkout@v4 + - uses: ./.github/actions/install_thinkfan_deps + - uses: ./.github/actions/build_thinkfan + - uses: ./.github/actions/install_thinkfan diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index b5e813a..00bb95d 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -27,10 +27,9 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - - name: install-deps - run: sudo apt install libyaml-cpp-dev libatasmart-dev cmake libsensors4-dev + - uses: ./.github/actions/install_thinkfan_deps # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL @@ -44,12 +43,7 @@ jobs: # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs queries: +security-and-quality - - - name: build - run: | - mkdir build - cmake -B build - cmake --build build + - uses: ./.github/actions/build_thinkfan - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2