ci: adjust naming in workflows (#88)

* ci: remove `latest` branch from triggering workflow run

* ci: adjust job names in workflows

* ci: adjust step names in workflow jobs

* docs(readme): adjust naming in the example workflows

* ci: rename `test.yml` workflow to `test.yaml`
This commit is contained in:
Alfi Maulana 2023-11-22 09:59:54 +07:00 committed by GitHub
parent 434fbed336
commit b3dad4773e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 43 deletions

View File

@ -20,20 +20,20 @@ jobs:
- name: Update Yarn - name: Update Yarn
run: corepack enable && yarn set version stable run: corepack enable && yarn set version stable
- name: Cache deps - name: Cache Dependencies
uses: actions/cache@v3.3.2 uses: actions/cache@v3.3.2
with: with:
path: .yarn path: .yarn
key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }} key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- name: Install deps - name: Install Dependencies
run: yarn install run: yarn install
- name: Check lib - name: Check Package
run: yarn check run: yarn check
- name: Bundle dist - name: Bundle Package
run: yarn bundle run: yarn bundle
- name: Check diff - name: Check Differences
run: git diff --exit-code HEAD run: git diff --exit-code HEAD

View File

@ -3,7 +3,7 @@ on:
workflow_dispatch: workflow_dispatch:
pull_request: pull_request:
push: push:
branches: [latest, main] branches: [main]
jobs: jobs:
test-package: test-package:
name: Test Package name: Test Package
@ -23,78 +23,81 @@ jobs:
with: with:
node-version: latest node-version: latest
- name: Cache deps - name: Cache Dependencies
uses: actions/cache@v3.3.2 uses: actions/cache@v3.3.2
with: with:
path: .yarn path: .yarn
key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }} key: yarn-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
- name: Install deps - name: Install Dependencies
run: corepack enable && yarn install run: corepack enable && yarn install
- name: Test lib - name: Test Package
run: yarn test run: yarn test
default-usage: test-action:
name: Test Action
runs-on: ${{ matrix.os }}-latest runs-on: ${{ matrix.os }}-latest
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [windows, ubuntu, macos] os: [windows, ubuntu, macos]
steps: steps:
- name: Checkout the repository - name: Checkout
uses: actions/checkout@v4.1.1 uses: actions/checkout@v4.1.1
- name: Move the test project to the working directory - name: Move Project
run: mv test/* . run: mv test/* .
- name: Use the action - name: Configure Project
id: cmake-action id: cmake-action
uses: ./ uses: ./
- name: Try to test the project - name: Try to Test Project
id: failed-step id: failed-step
continue-on-error: true continue-on-error: true
run: ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R hello_world ${{ matrix.os == 'windows' && '-C Debug' || '' }} run: ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R hello_world ${{ matrix.os == 'windows' && '-C Debug' || '' }}
- name: Check on success - name: Previous Step Should Failed
if: steps.failed-step.outcome == 'success' if: steps.failed-step.outcome == 'success'
run: exit 1 run: exit 1
- name: Build and test the project - name: Build and Test Project
run: | run: |
cmake --build ${{ steps.cmake-action.outputs.build-dir }} cmake --build ${{ steps.cmake-action.outputs.build-dir }}
ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R hello_world ${{ matrix.os == 'windows' && '-C Debug' || '' }} ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R hello_world ${{ matrix.os == 'windows' && '-C Debug' || '' }}
specified-dir-usage: test-action-with-specified-dirs:
name: Test Action With Specified Directories
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout the repository - name: Checkout
uses: actions/checkout@v4.1.1 uses: actions/checkout@v4.1.1
- name: Use the action with specified directories - name: Configure Project
id: cmake-action id: cmake-action
uses: ./ uses: ./
with: with:
source-dir: test source-dir: test
build-dir: output build-dir: output
- name: Check if the default build directory does not exist - name: Default Build Directory Should Not Exist
shell: bash shell: bash
run: test ! -e build && test ! -e test/build run: test ! -e build && test ! -e test/build
- name: Build and test the project - name: Build and Test Project
run: | run: |
cmake --build ${{ steps.cmake-action.outputs.build-dir }} cmake --build ${{ steps.cmake-action.outputs.build-dir }}
ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R hello_world ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R hello_world
run-build-usage: test-action-with-run-build:
name: Test Action With Run Build
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout the repository - name: Checkout
uses: actions/checkout@v4.1.1 uses: actions/checkout@v4.1.1
- name: Use the action with run build enabled - name: Configure and Build Project
id: cmake-action id: cmake-action
uses: ./ uses: ./
with: with:
@ -102,33 +105,35 @@ jobs:
run-build: true run-build: true
build-args: --target test_c --target test_cpp build-args: --target test_c --target test_cpp
- name: Test the project - name: Test Project
run: ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R test run: ctest --test-dir ${{ steps.cmake-action.outputs.build-dir }} --output-on-failure --no-tests=error -R test
run-test-usage: test-action-with-run-test:
name: Test Action With Run Test
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout the repository - name: Checkout
uses: actions/checkout@v4.1.1 uses: actions/checkout@v4.1.1
- name: Use the action with run test enabled - name: Configure, Build, and Test Project
uses: ./ uses: ./
with: with:
source-dir: test source-dir: test
run-test: true run-test: true
test-args: -R hello_world test-args: -R hello_world
additional-flags-usage: test-action-with-additional-args:
name: Test Action With Additional Arguments
runs-on: ${{ matrix.compiler == 'msvc' && 'windows' || 'ubuntu' }}-latest runs-on: ${{ matrix.compiler == 'msvc' && 'windows' || 'ubuntu' }}-latest
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
compiler: [gcc, msvc] compiler: [gcc, msvc]
steps: steps:
- name: Checkout the repository - name: Checkout
uses: actions/checkout@v4.1.1 uses: actions/checkout@v4.1.1
- name: Use the action with additional compiler flags - name: Configure, Build, and Test Project
uses: ./ uses: ./
with: with:
source-dir: test source-dir: test
@ -140,17 +145,18 @@ jobs:
run-test: true run-test: true
test-args: -R test ${{ matrix.compiler == 'msvc' && '-C Debug' || '' }} test-args: -R test ${{ matrix.compiler == 'msvc' && '-C Debug' || '' }}
specified-generator-and-compiler-usage: test-action-with-custom-tools:
name: Test Action With Custom Tools
runs-on: ${{ matrix.os }}-latest runs-on: ${{ matrix.os }}-latest
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
os: [windows, ubuntu, macos] os: [windows, ubuntu, macos]
steps: steps:
- name: Checkout the repository - name: Checkout
uses: actions/checkout@v4.1.1 uses: actions/checkout@v4.1.1
- name: Use the action with specified generator and compilers - name: Configure, Build, and Test Project
uses: ./ uses: ./
with: with:
source-dir: test source-dir: test

View File

@ -3,7 +3,7 @@
[![Latest Version](https://img.shields.io/github/v/release/threeal/cmake-action)](https://github.com/threeal/cmake-action/releases/) [![Latest Version](https://img.shields.io/github/v/release/threeal/cmake-action)](https://github.com/threeal/cmake-action/releases/)
[![License](https://img.shields.io/github/license/threeal/cmake-action)](./LICENSE) [![License](https://img.shields.io/github/license/threeal/cmake-action)](./LICENSE)
[![Build Status](https://img.shields.io/github/actions/workflow/status/threeal/cmake-action/build.yaml?branch=main)](https://github.com/threeal/cmake-action/actions/workflows/build.yaml) [![Build Status](https://img.shields.io/github/actions/workflow/status/threeal/cmake-action/build.yaml?branch=main)](https://github.com/threeal/cmake-action/actions/workflows/build.yaml)
[![Test Status](https://img.shields.io/github/actions/workflow/status/threeal/cmake-action/test.yml?label=test&branch=main)](https://github.com/threeal/cmake-action/actions/workflows/test.yml) [![Test Status](https://img.shields.io/github/actions/workflow/status/threeal/cmake-action/test.yaml?label=test&branch=main)](https://github.com/threeal/cmake-action/actions/workflows/test.yaml)
Configure, build, and test your [CMake](https://cmake.org/) project using [GitHub Actions](https://github.com/features/actions). This action simplifies the workflow for configuring the build environment of a CMake project. It can also be optionally specified to build a CMake project using the `cmake --build` command and test it using the `ctest` command. Configure, build, and test your [CMake](https://cmake.org/) project using [GitHub Actions](https://github.com/features/actions). This action simplifies the workflow for configuring the build environment of a CMake project. It can also be optionally specified to build a CMake project using the `cmake --build` command and test it using the `ctest` command.
@ -55,18 +55,19 @@ on:
push: push:
jobs: jobs:
build-project: build-project:
name: Build Project
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout the repository - name: Checkout
uses: actions/checkout@v3.5.3 uses: actions/checkout@v4.1.1
- name: Configure the project - name: Configure Project
uses: threeal/cmake-action@v1.3.0 uses: threeal/cmake-action@v1.3.0
- name: Build the project - name: Build Project
runs: cmake --build build runs: cmake --build build
- name: Test the project - name: Test Project
runs: ctest --test-dir build runs: ctest --test-dir build
``` ```
@ -75,7 +76,7 @@ jobs:
#### Configure, Build, and Test in the Same Step #### Configure, Build, and Test in the Same Step
```yaml ```yaml
- name: Configure, build, and test the project - name: Configure, Build, and Test Project
uses: threeal/cmake-action@v1.3.0 uses: threeal/cmake-action@v1.3.0
with: with:
run-build: true run-build: true
@ -85,7 +86,7 @@ jobs:
#### Specify the Source and Build Directories #### Specify the Source and Build Directories
```yaml ```yaml
- name: Configure the project - name: Configure Project
uses: threeal/cmake-action@v1.3.0 uses: threeal/cmake-action@v1.3.0
with: with:
source-dir: submodules source-dir: submodules
@ -95,7 +96,7 @@ jobs:
#### Using Ninja as the Generator and Clang as the Compiler #### Using Ninja as the Generator and Clang as the Compiler
```yaml ```yaml
- name: Configure the project - name: Configure Project
uses: threeal/cmake-action@v1.3.0 uses: threeal/cmake-action@v1.3.0
with: with:
generator: Ninja generator: Ninja