Skip to content

Commit

Permalink
Add check requirements workflow (#132)
Browse files Browse the repository at this point in the history
* Add workflow to check requirements in pull requests

Signed-off-by: Sun, Xuehao <[email protected]>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Signed-off-by: Sun, Xuehao <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
XuehaoSun and pre-commit-ci[bot] authored Jun 3, 2024
1 parent 8a5ef62 commit 5c59dce
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/bum_list_check.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 5c59dce

Please sign in to comment.