Skip to content

Commit

Permalink
chore: auto update reproducible requirements when there is a dependen…
Browse files Browse the repository at this point in the history
…cy change (#5677)

* chore: add reproducible gha

* format

* formatting v2

* format v3

* use win make target

* update windows job

* update win paths

* why windows why

* remove if stmt for now

* test with direct paths

* update windows paths again

* bring back activate

* add dummy win file and push changes

* update base.txt for testing

* Update reproducibles

* run jobs sequentially

* print changed flag

* check changes again

* run git status before moving forward

* refresh index before checking any changed files

* Update reproducibles

* commit or skip

* Update reproducibles

* rerun build & pyinstaller jobs once update reproducible finishes

* add more details to commit message

* nuke all reproducibles to trigger the CI

* Update reproducibles: update-reproducible-linux-reqs

* Update reproducibles: update-reproducible-mac-reqs

* Update reproducibles: update-reproducible-win-reqs

* change lb version for testing

* update permissions and limit only for aws/aws-sam-cli

* Update reproducibles: update-reproducible-linux-reqs

* Update reproducibles: update-reproducible-mac-reqs

* Update reproducibles: update-reproducible-win-reqs

* update other jobs as well

* run without file filter

* Update reproducibles: update-reproducible-linux-reqs

* Update reproducibles: update-reproducible-mac-reqs

* Update reproducibles: update-reproducible-win-reqs

* put the file filter back

---------

Co-authored-by: GitHub Action <action@github.com>
  • Loading branch information
mndeveci and actions-user authored Aug 3, 2023
1 parent b282ceb commit 8b67713
Show file tree
Hide file tree
Showing 6 changed files with 1,481 additions and 548 deletions.
16 changes: 2 additions & 14 deletions .github/workflows/automated-updates-to-sam-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,6 @@ jobs:
with:
repository: aws/aws-sam-cli
path: aws-sam-cli

- uses: actions/setup-python@v4 # used for make update-reproducible-reqs below
with:
python-version: |
3.8
3.11

- name: Update aws-sam-translator & commit
run: |
Expand All @@ -90,7 +84,7 @@ jobs:
SAM_T_PRE_VERSION=$(grep "aws-sam-translator=" requirements/base.txt)
echo "SAM-T pre version is $SAM_T_PRE_VERSION"
git reset --hard develop
sed -i "s/$SAM_T_PRE_VERSION/aws-sam-translator==$SAM_T_CUR_VERSION/g" requirements/base.txt; make update-reproducible-reqs
sed -i "s/$SAM_T_PRE_VERSION/aws-sam-translator==$SAM_T_CUR_VERSION/g" requirements/base.txt
cp -r ../serverless-application-model/tests/translator/input ./tests/functional/commands/validate/lib/models
git status
git diff --quiet && exit 0 # exit if there is no change
Expand Down Expand Up @@ -129,12 +123,6 @@ jobs:
repository: aws/aws-sam-cli
path: aws-sam-cli

- uses: actions/setup-python@v4 # used for make update-reproducible-reqs below
with:
python-version: |
3.8
3.11
- name: Upgrade aws_lambda_builders & commit
run: |
git config --global user.email "action@github.com"
Expand All @@ -147,7 +135,7 @@ jobs:
BUILDERS_PRE_VERSION=$(grep "aws_lambda_builders=" requirements/base.txt)
echo "Lambda Builders pre version is $BUILDERS_PRE_VERSION"
git reset --hard develop
sed -i "s/$BUILDERS_PRE_VERSION/aws_lambda_builders==$BUILDERS_CUR_VERSION/g" requirements/base.txt; make update-reproducible-reqs
sed -i "s/$BUILDERS_PRE_VERSION/aws_lambda_builders==$BUILDERS_CUR_VERSION/g" requirements/base.txt
git status
git diff --quiet && exit 0 # exit if there is no change
echo "is_new_lambda_builders=1" >> $GITHUB_ENV # set env variable for next step run decision
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/update-reproducibles.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Update reproducible requirements
on:
pull_request:
branches: [develop]
paths:
- requirements/base.txt # run this GHA only if requirements file is changed

jobs:
update-reqs:
permissions:
pull-requests: write
contents: write
if: github.repository_owner == 'aws'
strategy:
matrix:
include:
- os: ubuntu-latest
python: 3.11
target: update-reproducible-linux-reqs
- os: macos-latest
python: 3.8
target: update-reproducible-mac-reqs
- os: windows-latest
python: 3.8
target: update-reproducible-win-reqs
max-parallel: 1
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- run: make ${{ matrix.target }}
- name: Push changes
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git commit -am "Update reproducibles: ${{ matrix.target }}" || echo "nothing to commit"
git push
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,13 @@ update-reproducible-mac-reqs:
venv-update-reproducible-mac/bin/pip install -r requirements/base.txt
venv-update-reproducible-mac/bin/pip-compile --generate-hashes --allow-unsafe -o requirements/reproducible-mac.txt

# note that this should be run on a windows environment with python3.8 as default interpreter
update-reproducible-win-reqs:
python -m venv venv-update-reproducible-win
.\venv-update-reproducible-win\Scripts\activate
pip install --upgrade pip-tools pip
pip install -r requirements\base.txt
pip-compile --generate-hashes --allow-unsafe -o requirements\reproducible-win.txt


update-reproducible-reqs: update-reproducible-linux-reqs update-reproducible-mac-reqs
Loading

0 comments on commit 8b67713

Please sign in to comment.