Skip to content

Commit

Permalink
Merge pull request #6 from gojekfarm/fix/mergeable-status
Browse files Browse the repository at this point in the history
fix: Fixing Mergeable issue
  • Loading branch information
HB-Balaji authored Feb 26, 2024
2 parents d563366 + a5e3abc commit fcdf954
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 56 deletions.
121 changes: 73 additions & 48 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,73 +3,98 @@ name: tester
on:
push:
branches:
- "main"
paths:
- '**.go'
- 'go.*'
- '.github/workflows/test.yml'
- 'main'
- 'release-**'
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
branches:
- "main"
paths:
- '**.go'
- 'go.*'
- '.github/workflows/test.yml'

- 'main'
- 'release-**'

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
test:
changes:
outputs:
should-run-tests: ${{ steps.changes.outputs.go == 'true' }}
if: github.event.pull_request.draft == false
name: runner / gotest
runs-on: ubuntu-22.04
container: ghcr.io/runatlantis/testing-env:latest
steps:
- uses: actions/checkout@v3
- run: make test-all
- run: make check-fmt

# Check that there's no missing links for the website.
# This job builds the website, starts a server to serve it, and then uses
# muffet (https://github.com/raviqqe/muffet) to perform the link check.
website_link_check:
if: github.event.pull_request.draft == false
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: changes
with:
filters: |
go:
- '**.go'
- 'go.*'
- '.github/workflows/test.yml'
test:
needs: [changes]
if: needs.changes.outputs.should-run-tests == 'true'
name: Tests
runs-on: ubuntu-22.04
container: ghcr.io/runatlantis/testing-env:latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-node@v3
# need to setup go toolchain explicitly
- uses: actions/setup-go@v5
with:
node-version-file: .node-version
go-version-file: go.mod

- name: run http-server
- run: make test-all
- run: make check-fmt
###########################################################
# Notifying #contributors about test failure on main branch
###########################################################
- name: Slack failure notification
if: ${{ github.ref == 'refs/heads/main' && failure() }}
uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 # v1.25.0
with:
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":x: Failed GitHub Action:"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Workflow:*\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|${{ github.workflow }}>"
},
{
"type": "mrkdwn",
"text": "*Job:*\n${{ github.job }}"
},
{
"type": "mrkdwn",
"text": "*Repo:*\n${{ github.repository }}"
}
]
}
]
}
env:
# renovate: datasource=github-releases depName=raviqqe/muffet
MUFFET_VERSION: 2.6.3
run: |
npm install -g yarn
# http-server is used to serve the website locally as muffet checks it.
yarn global add http-server
# install raviqqe/muffet to check for broken links.
curl -L https://github.com/raviqqe/muffet/releases/download/v${MUFFET_VERSION}/muffet_${MUFFET_VERSION}_Linux_x86_64.tar.gz | tar -xz
yarn install
yarn website:build
http-server runatlantis.io/.vuepress/dist &
- name: wait until server listened
run: curl --retry-delay 1 --retry 30 --retry-all-error http://localhost:8080
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

- run: |
./muffet \
-e 'https://github\.com/runatlantis/atlantis/edit/main/.*' \
-e 'https://github.com/runatlantis/helm-charts#customization' \
--header 'Accept-Encoding:deflate, gzip' \
--buffer-size 8192 \
http://localhost:8080/
skip-test:
needs: [changes]
if: needs.changes.outputs.should-run-tests == 'false'
name: Tests
runs-on: ubuntu-22.04
steps:
- run: 'echo "No build required"'
2 changes: 1 addition & 1 deletion server/core/terraform/terraform_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ terraform {
"<= 1.0": "1.0.0",
// cannot use ~> 1.3 or ~> 1.0 since that is a moving target since it will always
// resolve to the latest terraform 1.x
"~> 1.3.0": "1.3.9",
"~> 1.3.0": "1.3.10",
}

type testCase struct {
Expand Down
18 changes: 11 additions & 7 deletions server/events/vcs/gitlab_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,13 +310,17 @@ func (g *GitlabClient) PullIsMergeable(repo models.Repo, pull models.PullRequest
return false, err
}

if ((ok && (mr.DetailedMergeStatus == "mergeable" || mr.DetailedMergeStatus == "ci_still_running")) ||
(!ok && mr.MergeStatus == "can_be_merged")) &&
mr.ApprovalsBeforeMerge <= 0 &&
mr.BlockingDiscussionsResolved &&
!mr.WorkInProgress &&
(allowSkippedPipeline || !isPipelineSkipped) {
return true, nil
retryLimit := 6
for attempt := 0; attempt < retryLimit; attempt++ {
if ((ok && (mr.DetailedMergeStatus == "mergeable" || mr.DetailedMergeStatus == "ci_still_running")) ||
(!ok && mr.DetailedMergeStatus == "can_be_merged")) &&
mr.ApprovalsBeforeMerge <= 0 &&
mr.BlockingDiscussionsResolved &&
!mr.WorkInProgress &&
(allowSkippedPipeline || !isPipelineSkipped) {
return true, nil
}
time.Sleep(10 * time.Second)
}
return false, nil
}
Expand Down

0 comments on commit fcdf954

Please sign in to comment.