Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
hdinia committed Jan 30, 2024
1 parent 1823db2 commit 7bd80e7
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 3 deletions.
39 changes: 36 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ on:
push:
branches:
- "**"
pull_request:
types: [opened, synchronize, reopened]

jobs:
python-lint:
Expand Down Expand Up @@ -38,7 +40,7 @@ jobs:
strategy:
max-parallel: 9
matrix:
os: [ windows-latest, ubuntu-20.04 ]
os: [windows-latest, ubuntu-20.04]

steps:
- name: Checkout github repo (+ download lfs dependencies)
Expand Down Expand Up @@ -69,7 +71,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-20.04 ]
os: [ubuntu-20.04]
steps:
- name: Checkout github repo
uses: actions/checkout@v3
Expand All @@ -92,7 +94,7 @@ jobs:

sonarcloud:
runs-on: ubuntu-20.04
needs: [ python-test, npm-test ]
needs: [python-test, npm-test]
steps:
- uses: actions/checkout@v3
- name: Download python coverage report
Expand All @@ -104,3 +106,34 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

auto-merge-or-squash:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Determine Merge Method
id: merge-method
run: |
base_branch="${{ github.event.pull_request.base.ref }}"
if [[ -z "$base_branch" ]]; then
base_branch="main"
fi
commit_count=$(git rev-list --count HEAD ^$base_branch)
echo "Commit Count: $commit_count"
if [ "$commit_count" -eq "1" ]; then
echo "::set-output name=METHOD::squash"
else
echo "::set-output name=METHOD::merge"
fi
- name: Apply Merge Method
run: |
echo "Merge Method: ${{ steps.merge-method.outputs.METHOD }}"
gh pr merge ${{ github.event.pull_request.number }} --merge-method ${{ steps.merge-method.outputs.METHOD }} --repo $GITHUB_REPOSITORY
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32 changes: 32 additions & 0 deletions .github/workflows/pr-management.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: PR Management

on:
pull_request:
branches: [test-actions] # TODO only for tests to be removed
types: [opened, synchronize, reopened]

jobs:
auto-merge-or-squash:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Determine Merge Method
id: merge-method
run: |
commit_count=$(git rev-list --count HEAD ^$GITHUB_BASE_REF)
echo "Commit Count: $commit_count"
if [ "$commit_count" -eq "1" ]; then
echo "::set-output name=METHOD::squash"
else
echo "::set-output name=METHOD::merge"
fi
- name: Apply Merge Method
run: |
echo "Merge Method: ${{ steps.merge-method.outputs.METHOD }}"
gh pr merge ${{ github.event.pull_request.number }} --merge-method ${{ steps.merge-method.outputs.METHOD }} --repo $GITHUB_REPOSITORY
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 7bd80e7

Please sign in to comment.