Enable Github Actions to check below items: - RedfishClientPkg build check on push and pull request - Uncrustify check on pull request
Signed-off-by: Nickle Wang <nick...@nvidia.com> Cc: Abner Chang <abner.ch...@amd.com> Cc: Igor Kulchytskyy <ig...@ami.com> --- .github/.github/workflows/build.sh | 70 +++++++++++++++++++ .github/.github/workflows/build.yml | 61 ++++++++++++++++ .github/.github/workflows/uncrustify-check.sh | 51 ++++++++++++++ .github/.github/workflows/uncrustify.yml | 44 ++++++++++++ 4 files changed, 226 insertions(+) create mode 100755 .github/.github/workflows/build.sh create mode 100644 .github/.github/workflows/build.yml create mode 100755 .github/.github/workflows/uncrustify-check.sh create mode 100644 .github/.github/workflows/uncrustify.yml diff --git a/.github/.github/workflows/build.sh b/.github/.github/workflows/build.sh new file mode 100755 index 00000000..f919d551 --- /dev/null +++ b/.github/.github/workflows/build.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# +# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# + + +ARCH="X64" +TARGET="DEBUG" +TOOLCHAIN="GCC5" + +if [ $# -eq 0 ] +then + echo "usage: $0 [path to edk2] [path to edk2-redfish-client] [ARCH] [TARGET] [TOOLCHAIN]" + exit 1 +fi + +EDK2_ROOT="$PWD/$1" +EDK2_REDFISH_CLIENT="$PWD/$2" +ARCH="$3" +TARGET="$4" +TOOLCHAIN="$5" + +if [ ! -e "$EDK2_ROOT" ] +then + echo "$EDK2_ROOT does not exist" + exit 1 +fi + +if [ ! -e "$EDK2_REDFISH_CLIENT" ] +then + echo "$EDK2_REDFISH_CLIENT does not exist" + exit 1 +fi + +export PACKAGES_PATH="$EDK2_ROOT:$EDK2_REDFISH_CLIENT" +echo "PACKAGES_PATH: $PACKAGES_PATH" +echo "ARCH: $ARCH" +echo "TARGET: $TARGET" +echo "TOOLCHAIN: $TOOLCHAIN" + +cd "$EDK2_ROOT" +. edksetup.sh BaseTools + +if [ ! -e "BaseTools/Source/C/bin" ] +then + echo "binary does not exist, rebuild it" + + cd BaseTools + make + cd .. + + echo "If there is build error related to nasm, try to use latest nasm from: https://www.nasm.us/pub/nasm/releasebuilds/" + echo "" + echo "1) wget https://www.nasm.us/pub/nasm/releasebuilds/2.15rc12/nasm-2.15rc12.tar.gz" + echo "2) tar zxvf nasm-2.15rc12.tar.gz" + echo "3) cd nasm-2.15rc12" + echo "4) ./configure --prefix=/usr" + echo "5) sudo make install" + echo "6) nasm -v" +fi + +build -p RedfishClientPkg/RedfishClientPkg.dsc -a $ARCH -t $TOOLCHAIN -b $TARGET +if [ $? -ne 0 ] +then + exit 1 +fi + +exit 0 diff --git a/.github/.github/workflows/build.yml b/.github/.github/workflows/build.yml new file mode 100644 index 00000000..f44184b3 --- /dev/null +++ b/.github/.github/workflows/build.yml @@ -0,0 +1,61 @@ +# @file +# GitHub Workflow for build checks +# +# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## +name: "RedfishClientPkg Build" +on: + push: + branches: + - main + pull_request: + branches: + - main + paths-ignore: + - '**/*.bat' + - '**/*.md' + - '**/*.py' + - '**/*.rst' + - '**/*.sh' + - '**/*.txt' + +jobs: + edk2-redfish-client-build: + strategy: + fail-fast: false + matrix: + include: + - Target: "DEBUG" + ArchList: "X64" + ToolChain: "GCC5" + - Target: "RELEASE" + ArchList: "X64" + ToolChain: "GCC5" + - Target: "NOOPT" + ArchList: "X64" + ToolChain: "GCC5" + runs-on: ubuntu-latest + container: + image: ghcr.io/tianocore/containers/ubuntu-22-dev:latest + options: --user root -v ${{ github.workspace }}:/home/edk2 + env: + EDK2_DOCKER_USER_HOME: "/home/edk2" + name: edk2 build test + steps: + - name: checkout edk2 + uses: actions/checkout@v3 + with: + repository: tianocore/edk2 + path: ./edk2 + submodules: recursive + - name: checkout edk2-redfish-client + uses: actions/checkout@v3 + with: + path: ./edk2-redfish-client + - name: edk2 build + run: | + ./edk2-redfish-client/.github/workflows/build.sh ./edk2 ./edk2-redfish-client ${{ matrix.ArchList }} ${{ matrix.Target }} ${{ matrix.ToolChain }} + shell: bash + diff --git a/.github/.github/workflows/uncrustify-check.sh b/.github/.github/workflows/uncrustify-check.sh new file mode 100755 index 00000000..b739a60b --- /dev/null +++ b/.github/.github/workflows/uncrustify-check.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# +# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# + + +if [ $# -ne 3 ] +then + echo "usage: $0 [PATH to CONFIG FILE] [PATH to REPO.] [NO. of COMMITS]" + exit 1 +fi + +CONFIG_FILE="$PWD/$1" +REPO_PATH="$PWD/$2" +NO_COMMITS="$3" + +if [ ! -e "$CONFIG_FILE" ] +then + echo "$CONFIG_FILE does not exist" + exit 1 +fi + +if [ ! -e "$REPO_PATH" ] +then + echo "$REPO_PATH does not exist" + exit 1 +fi + +cd "$REPO_PATH" + +FAILURE=0 +CHANGED_FILES=$(git diff --name-only HEAD~$NO_COMMITS) +for file in $CHANGED_FILES +do + echo "Uncrustify check file: $file" + uncrustify -c $CONFIG_FILE -f $file --check + if [ $? -ne 0 ] + then + echo "Uncrustify check failure on file: $file" + FAILURE=1 + fi +done + +if [ $FAILURE -eq 0 ] +then + exit 0 +fi + +exit 1 diff --git a/.github/.github/workflows/uncrustify.yml b/.github/.github/workflows/uncrustify.yml new file mode 100644 index 00000000..aa603c8d --- /dev/null +++ b/.github/.github/workflows/uncrustify.yml @@ -0,0 +1,44 @@ +# @file +# GitHub Workflow for uncrustify check +# +# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## +name: "Uncrustify check" +on: + pull_request: + branches: + - main + paths: + - '**/*.h' + - '**/*.c' + +jobs: + uncrustify-check: + runs-on: ubuntu-latest + name: Uncrustify check + steps: + - name: checkout edk2 + uses: actions/checkout@v3 + with: + repository: tianocore/edk2 + path: ./edk2 + - name: checkout edk2-redfish-client + uses: actions/checkout@v3 + with: + path: ./edk2-redfish-client + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + - name: uncrustify setup + run: | + git clone https://projec...@dev.azure.com/projectmu/Uncrustify/_git/Uncrustify uncrustify-edk2 + cd uncrustify-edk2 + mkdir build + cd build + cmake .. + cmake --build . + cp uncrustify /usr/local/bin && chmod +x /usr/local/bin/uncrustify + - name: uncrustify check changed files + run: ./edk2-redfish-client/.github/workflows/uncrustify-check.sh ./edk2/.pytool/Plugin/UncrustifyCheck/uncrustify.cfg ./edk2-redfish-client ${{ github.event.pull_request.commits }} + shell: bash -- 2.17.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#105870): https://edk2.groups.io/g/devel/message/105870 Mute This Topic: https://groups.io/mt/99388066/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-