next.update1 #3
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
name: Validate pip requirements-fixed.txt | ||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened] | ||
branches: | ||
- main | ||
- 'v*-branch' | ||
paths: | ||
- 'scripts/requirements*.txt' | ||
jobs: | ||
build: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Determine PR Origin | ||
id: pr-origin | ||
run: | | ||
echo "PR owner: ${{ github.event.pull_request.head.repo.owner.login }}" | ||
echo "PR repo name: ${{ github.event.pull_request.head.repo.name }}" | ||
echo "::set-output name=pr_owner::${{ github.event.pull_request.head.repo.owner.login }}" | ||
echo "::set-output name=pr_repo_name::${{ github.event.pull_request.head.repo.name }}" | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: refs/pull/${{ github.event.pull_request.number }}/head | ||
path: ncs/nrf | ||
fetch-depth: 0 | ||
- name: Get python version | ||
id: pyv | ||
run: | | ||
sudo snap install --channel=v4 yq | ||
PYTHON_VERSION=$(yq '.python.version' ./ncs/nrf/scripts/tools-versions-linux.yml) | ||
echo "python_version=$PYTHON_VERSION" >> $GITHUB_OUTPUT | ||
- name: Setup python version | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '${{ steps.pyv.outputs.python_version }}' | ||
- name: Setup environment | ||
working-directory: ncs | ||
run: | | ||
pip3 install --user -U setuptools wheel pip virtualenv virtualenvwrapper | ||
pip3 install -r nrf/scripts/requirements-base.txt | ||
west init -l nrf | ||
west update mcuboot zephyr | ||
- name: Generate new requirements-fixed.txt | ||
working-directory: ncs | ||
run: nrf/scripts/fix-requirements.sh requirements-fixed.txt | ||
- name: Store requirements-fixed | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: requirements-fixed | ||
path: ncs/requirements-fixed.txt | ||
- name: Compare requirements-fixed | ||
id: diff | ||
run: | | ||
NEW=ncs/requirements-fixed.txt | ||
OLD=ncs/nrf/scripts/requirements-fixed.txt | ||
DIFF_OUTPUT=$(diff -y $NEW $OLD) || true # Add || true to avoid step failure | ||
if [[ -n "$DIFF_OUTPUT" ]]; then | ||
echo "Differences found! Making autocommit" | ||
echo "difference=true" >> $GITHUB_OUTPUT | ||
echo '${{ steps.diff.outputs.difference }}' | ||
else | ||
echo "No differences found." | ||
echo "difference=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Commit and push changes | ||
if: ${{ steps.diff.outputs.difference == 'true' }} | ||
working-directory: ncs/nrf | ||
run: | | ||
mv ../requirements-fixed.txt ./scripts/requirements-fixed.txt | ||
git config user.email "[email protected]" | ||
git config user.name "NordicBuilder" | ||
git add ./scripts/requirements-fixed.txt | ||
git commit -F- <<EOF | ||
Update requirements-fixed.txt from NordicBuilder | ||
Automatically upload changed requirements-fixed.txt | ||
Signed-off-by: Nordic Builder <[email protected]> | ||
EOF | ||
git remote set-url origin https://${{ secrets.NCS_GITHUB_TOKEN }}@github.com/${{ steps.pr-origin.outputs.pr_repo_name }}/sdk-nrf-testing.git | ||
git push origin HEAD:${{ github.head_ref }} | ||
- name: Post summary | ||
if: ${{ !cancelled() }} | ||
run: | | ||
if [[ "failure" == "${{ steps.diff.outcome }}" ]]; then | ||
echo -e 'New requirements-fixed.txt file differs from the current file. | ||
Please add the newly created file to the PR.' >> $GITHUB_STEP_SUMMARY | ||
fi | ||
if [[ -e ncs/requirements-fixed.txt ]]; then | ||
echo -e ' | ||
<details> | ||
<summary>requirements-fixed.txt</summary> | ||
```' >> $GITHUB_STEP_SUMMARY | ||
cat ncs/requirements-fixed.txt >> $GITHUB_STEP_SUMMARY | ||
echo -e '``` | ||
</details>' >> $GITHUB_STEP_SUMMARY | ||
else | ||
echo -e 'Error during workflow, requirements-fixed file was not created' >> GITHUB_STEP_SUMMARY | ||
fi |