Skip to content

Update requirements-base.txt #63

Update requirements-base.txt

Update requirements-base.txt #63

name: Compile requirements-fixed.txt and push to PR
on:
pull_request_target:
paths:
- 'scripts/requirements.txt'
- 'scripts/requirements-ci.txt'
- 'scripts/requirements-base.txt'
- 'scripts/requirements-build.txt'
permissions:
contents: write
jobs:
fix-requirements:
runs-on: ubuntu-20.04
steps:
- name: Checkout PR target branch
uses: actions/checkout@v4
with:
token: ${{ secrets.NCS_GITHUB_TOKEN }}
path: ncs/nrf
fetch-depth: 1
- name: Switch to PR source branch
working-directory: ncs/nrf
env:
GITHUB_TOKEN: ${{ secrets.NCS_GITHUB_TOKEN }}
run: gh pr checkout ${{ github.event.pull_request.number }}
- 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: Compile new requirements-fixed.txt
working-directory: ncs/nrf/scripts
run: ./compile-requirements.sh ./requirements-fixed.txt
- name: 'Upload Artifact: requirements-fixed.txt'
uses: actions/upload-artifact@v3
with:
name: requirements-fixed
path: ncs/nrf/scripts/requirements-fixed.txt
- name: Push `requirements-fixed.txt` to PR branch if changed
working-directory: ncs/nrf
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config user.email "[email protected]"
git config user.name "NordicBuilder"
git add scripts/requirements-fixed.txt
git diff --cached HEAD \
--exit-code \
--ignore-space-change \
--ignore-all-space \
--ignore-blank-lines \
--ignore-cr-at-eol \
--ignore-space-at-eol \
&& true
# `git diff` returns 0 if identical
if [ $? != 0 ]; then
echo -e '`requirements-fixed.txt` has changed. Pushing to PR branch.' >> $GITHUB_STEP_SUMMARY
git commit -s -m "Updating scripts/requirements-fixed.txt with new fixed versions" \
-m 'This is an automated commit from github workflow by NordicBuilder'
git push
else
echo -e 'No changes to `requirements-fixed.txt` needed.' >> $GITHUB_STEP_SUMMARY
fi