-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add check requirements workflow (#132)
* 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
1 parent
8a5ef62
commit 5c59dce
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |