From 5c59dce71dd57db4cea1e1a992b10d3288c2f5fc Mon Sep 17 00:00:00 2001 From: "Sun, Xuehao" Date: Mon, 3 Jun 2024 17:42:56 +0800 Subject: [PATCH] Add check requirements workflow (#132) * Add workflow to check requirements in pull requests Signed-off-by: Sun, Xuehao * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: Sun, Xuehao Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- .github/workflows/bum_list_check.yml | 51 ++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/bum_list_check.yml diff --git a/.github/workflows/bum_list_check.yml b/.github/workflows/bum_list_check.yml new file mode 100644 index 000000000..da9050861 --- /dev/null +++ b/.github/workflows/bum_list_check.yml @@ -0,0 +1,51 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +name: Check Requirements + +on: [pull_request] + +jobs: + check-requirements: + runs-on: ubuntu-latest + steps: + - name: Checkout PR branch + uses: actions/checkout@v4 + + - name: Save PR requirements + run: | + find . -name "requirements.txt" -exec cat {} \; | \ + grep -v '^\s*#' | \ + grep -v '^\s*$' | \ + grep -v '^\s*-' | \ + sed 's/^\s*//' | \ + awk -F'[>=<]' '{print $1}' | \ + sort -u > pr-requirements.txt + cat pr-requirements.txt + + - name: Checkout main branch + uses: actions/checkout@v4 + with: + ref: main + path: main-branch + + - name: Save main branch requirements + run: | + find ./main-branch -name "requirements.txt" -exec cat {} \; | \ + grep -v '^\s*#' | \ + grep -v '^\s*$' | \ + grep -v '^\s*-' | \ + sed 's/^\s*//' | \ + awk -F'[>=<]' '{print $1}' | \ + sort -u > main-requirements.txt + cat main-requirements.txt + + - name: Compare requirements + run: | + comm -23 pr-requirements.txt main-requirements.txt > added-packages.txt + if [ -s added-packages.txt ]; then + echo "New packages found in PR:" && cat added-packages.txt + exit 1 + else + echo "No new packages found😊." + fi