Skip to content

Commit

Permalink
Update push.yml to Auto-Commit Changes in pubspec.lock (#2701)
Browse files Browse the repository at this point in the history
* updated push.yml workflow adding pubspec.lock auto-commit

* added git push

* removed auto-commit and added git stash approach

* added auto-commit back and added check in check_ignore to ignore generated files

* added "git checkout develop-postgres"

* added postgres to git diff

* added develop-postgres in all required workflow files.

* re-run workflow

---------

Co-authored-by: Satyam Jha <[email protected]>
  • Loading branch information
may-tas and Satyam Jha authored Jan 13, 2025
1 parent c5c3ad6 commit d193685
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ This section can be deleted after reading.
We employ the following branching strategy to simplify the development process and to ensure that only stable code is pushed to the `master` branch:
- `develop`: For unstable code: New features and bug fixes.
- `develop-postgres`: For unstable code: New features and bug fixes.
- `master`: Where the stable production-ready code lies. Only security-related bugs.
NOTE!!!
ONLY SUBMIT PRS AGAINST OUR `DEVELOP` BRANCH. THE DEFAULT IS `MAIN`, SO YOU WILL HAVE TO MODIFY THIS BEFORE SUBMITTING YOUR PR FOR REVIEW. PRS MADE AGAINST `MAIN` WILL BE CLOSED.
ONLY SUBMIT PRS AGAINST OUR `DEVELOP-POSTGRES` BRANCH. THE DEFAULT IS `MAIN`, SO YOU WILL HAVE TO MODIFY THIS BEFORE SUBMITTING YOUR PR FOR REVIEW. PRS MADE AGAINST `MAIN` WILL BE CLOSED.
-->

<!--
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/check_ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,15 @@ def _check_for_ignore_directive(filePath):
"""

# Either it is a non-code file, or the file does not exist. This can happen when
# `develop` gets ahead of your branch and has some files which you don't have
# `develop-postgres` gets ahead of your branch and has some files which you don't have

if (not filePath.startswith('lib') or not filePath.endswith('.dart') or not os.path.exists(filePath)):
return False

# Exclude generated files
if 'generated' in filePath or filePath == 'lib/generated_plugin_registrant.dart':
return False

with open(filePath, "r") as file:
lines = file.readlines()

Expand Down Expand Up @@ -160,7 +164,7 @@ def main():

current_branch = subprocess.check_output(['git', 'branch', '--show-current']).decode('utf-8').strip('\n')
print(current_branch)
changed_files = subprocess.check_output(['git', 'diff', '--name-only', 'develop', current_branch]).decode('utf-8').splitlines()
changed_files = subprocess.check_output(['git', 'diff', '--name-only', 'develop-postgres', current_branch]).decode('utf-8').splitlines()
print(changed_files)


Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: "Congratulations on making your first Issue! :confetti_ball: If you haven't already, check out our [Contributing Guidelines](https://github.com/PalisadoesFoundation/talawa/blob/develop/CONTRIBUTING.md) and [Issue Reporting Guidelines](https://github.com/PalisadoesFoundation/talawa/blob/develop/ISSUE_GUIDELINES.md) to ensure that you are following our guidelines for contributing and making issues."
issue-message: "Congratulations on making your first Issue! :confetti_ball: If you haven't already, check out our [Contributing Guidelines](https://github.com/PalisadoesFoundation/talawa/blob/develop-postgres/CONTRIBUTING.md) and [Issue Reporting Guidelines](https://github.com/PalisadoesFoundation/talawa/blob/develop-postgres/ISSUE_GUIDELINES.md) to ensure that you are following our guidelines for contributing and making issues."
2 changes: 1 addition & 1 deletion .github/workflows/pull-request-target.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ jobs:
uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
pr-message: "Congratulations on making your first PR! :confetti_ball: If you haven't already, check out our [Contributing Guidelines](https://github.com/PalisadoesFoundation/talawa/blob/develop/CONTRIBUTING.md) and [PR Reporting Guidelines](https://github.com/PalisadoesFoundation/talawa/blob/develop/PR_GUIDELINES.md) to ensure that you are following our guidelines for contributing and creating PR."
pr-message: "Congratulations on making your first PR! :confetti_ball: If you haven't already, check out our [Contributing Guidelines](https://github.com/PalisadoesFoundation/talawa/blob/develop-postgres/CONTRIBUTING.md) and [PR Reporting Guidelines](https://github.com/PalisadoesFoundation/talawa/blob/develop-postgres/PR_GUIDELINES.md) to ensure that you are following our guidelines for contributing and creating PR."
16 changes: 8 additions & 8 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ name: PR Workflow
on:
pull_request:
branches-ignore:
- "master"
- 'master'

env:
CODECOV_UNIQUE_NAME: CODECOV_UNIQUE_NAME-${{ github.run_id }}-${{ github.run_number }}
Expand All @@ -30,12 +30,12 @@ jobs:
fetch-depth: 0
- uses: actions/setup-java@v4
with:
distribution: "zulu" # See 'Supported distributions' for available options
java-version: "17.0"
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17.0'
- uses: subosito/flutter-action@v2
with:
flutter-version: "3.22.3"
channel: "stable" # or: 'beta', 'dev' or 'master'
flutter-version: '3.22.3'
channel: 'stable' # or: 'beta', 'dev' or 'master'
- name: Set default branch.
run: git remote set-head origin --auto
shell: bash
Expand All @@ -59,10 +59,10 @@ jobs:
git checkout -b temp_branch
git branch
git stash push -m lock_file pubspec.lock
git checkout develop
git checkout develop-postgres
git pull
git branch
git diff --name-only develop..HEAD
git diff --name-only develop-postgres..HEAD
git checkout temp_branch
pip install GitPython
python ./.github/workflows/check_ignore.py --repository ${{github.repository}} --merge_branch_name ${{github.head_ref}}
Expand Down Expand Up @@ -169,7 +169,7 @@ jobs:
echo "Error: Too many files (greater than 100) changed in the pull request."
echo "Possible issues:"
echo "- Contributor may be merging into an incorrect branch."
echo "- Source branch may be incorrect please use develop as source branch."
echo "- Source branch may be incorrect please use develop-postgres as source branch."
exit 1
Flutter-Testing:
Expand Down
41 changes: 28 additions & 13 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# NOTE!
#
# Please read the README.md file in this directory that defines what should
# Please read the README.md file in this directory that defines what should
# be placed in this file
#
##############################################################################
Expand All @@ -19,21 +19,24 @@ on:
- "*"

env:
CODECOV_UNIQUE_NAME: CODECOV_UNIQUE_NAME-${{ github.run_id }}-${{ github.run_number }}

jobs:
CODECOV_UNIQUE_NAME: CODECOV_UNIQUE_NAME-${{ github.run_id }}-${{ github.run_number }}

jobs:

Flutter-Codebase-Check:
if: ${{ github.actor != 'dependabot[bot]' }}
name: Checking Codebase
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
# This is important to fetch all history for all branches and tags.
# This could be important for our documentation generation process.
# See: https://github.com/actions/checkout
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/setup-java@v4
with:
distribution: 'zulu' # See 'Supported distributions' for available options
Expand All @@ -46,6 +49,18 @@ jobs:
run: cd talawa_lint && flutter pub get && cd ..
- name: Running pub get to fetch dependencies
run: flutter pub get
- name: Check and commit pubspec.lock changes
run: |
if [[ $(git status --porcelain pubspec.lock) ]]; then
echo "Changes detected in pubspec.lock. Auto-committing updates."
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add pubspec.lock
git commit -m "Automated update of pubspec.lock"
git push
else
echo "No changes in pubspec.lock."
fi
- name: Checking for correct formatting of code
run: dart format --set-exit-if-changed .
- name: setup python
Expand All @@ -55,7 +70,7 @@ jobs:
- name: Run check_ignore
run: |
git branch
git checkout develop
git checkout develop-postgres
git pull
git branch
git checkout -
Expand All @@ -65,10 +80,10 @@ jobs:
run: flutter analyze --no-pub
- name: Analysing codebase for custom linting
run: dart run custom_lint
# - name: Echo the GitHub environment for troubleshooting
# run: echo "$GITHUB_CONTEXT"
# - name: Echo the GitHub context for troubleshooting
# run: echo "${{ toJSON(github) }}"
# - name: Echo the GitHub environment for troubleshooting
# run: echo "$GITHUB_CONTEXT"
# - name: Echo the GitHub context for troubleshooting
# run: echo "${{ toJSON(github) }}"


Flutter-Testing:
Expand All @@ -82,7 +97,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17.0'
java-version: '17.0'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.22.3'
Expand All @@ -99,7 +114,7 @@ jobs:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
fail_ci_if_error: false
name: '${{env.CODECOV_UNIQUE_NAME}}'
name: '${{env.CODECOV_UNIQUE_NAME}}'

Android-Build-and-Release:
if: ${{ github.actor != 'dependabot[bot]' }}
Expand All @@ -114,7 +129,7 @@ jobs:
- uses: actions/setup-java@v4
with:
distribution: 'zulu' # See 'Supported distributions' for available options
java-version: '17.0'
java-version: '17.0'
- uses: subosito/flutter-action@v2
with:
flutter-version: '3.22.3'
Expand Down Expand Up @@ -161,7 +176,7 @@ jobs:
########################################################
## Package the app as an .ipa and create a release ##
########################################################

- name: Releasing for iOS
run: |
mkdir Payload
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ jobs:
- uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.'
stale-pr-message: 'This pull request did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please verify it has no conflicts with the develop branch and rebase if needed. Mention it now if you need help or give permission to other people to finish your work.'
close-issue-message: 'This issue did not get any activity in the past 180 days and thus has been closed. Please check if the newest release or develop branch has it fixed. Please, create a new issue if the issue is not fixed.'
stale-issue-message: 'This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop-postgres branch has fixed it and report again or close the issue.'
stale-pr-message: 'This pull request did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please verify it has no conflicts with the develop-postgres branch and rebase if needed. Mention it now if you need help or give permission to other people to finish your work.'
close-issue-message: 'This issue did not get any activity in the past 180 days and thus has been closed. Please check if the newest release or develop-postgres branch has it fixed. Please, create a new issue if the issue is not fixed.'
close-pr-message: 'This pull request did not get any activity in the past 180 days and thus has been closed.'
stale-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity'
Expand Down

0 comments on commit d193685

Please sign in to comment.