Skip to content

Commit e959bb4

Browse files
motatoesrenovate[bot]duoctranthduoctt
authored
merge dev to pre 22 (#308)
* Update CONTRIBUTING.md (#303) * fix(deps): update module github.com/xanzy/go-gitlab to v0.84.0 (#306) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * fix(deps): update module github.com/stretchr/testify to v1.8.4 (#302) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * fix(deps): update module github.com/aws/aws-sdk-go to v1.44.268 (#290) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * feat: Add support for NoOp lock implementation (#278) Co-authored-by: duoctt <duoctt@vng.com.vn> --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Duoc Tran <51254650+duoctranth@users.noreply.github.com> Co-authored-by: duoctt <duoctt@vng.com.vn>
1 parent 9efa3a7 commit e959bb4

File tree

5 files changed

+41
-7
lines changed

5 files changed

+41
-7
lines changed

CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,18 @@ We strive to maintain a consistent coding style throughout the project. Please f
3939

4040
## Submitting a pull request
4141
When you have made changes to the codebase that you would like to contribute back, please follow these steps:
42-
1. Fork the repository and create a new branch from `main`.
42+
1. Fork the repository and create a new branch from `develop`.
4343
2. Make your changes and ensure that the code passes all tests.
4444
3. Write tests for your changes, if applicable.
4545
4. Update the documentation to reflect your changes, if applicable.
46-
5. Submit a pull request to the `main` branch.
46+
5. Submit a pull request to the `develop` branch.
4747
We will review your pull request as soon as possible. Please be patient and open to feedback. We appreciate your contributions!
4848

4949
## Release Process
5050
**NOTE: The default branch `@develop` is not guaranteed to be stable and you should always use published release versions in your testing and production.**
5151

5252
- All pull requests are merged to the default develop branch after initial unit tests and integration tests are passing and required code review requirements are met.
53-
- We checkout a pre-release branch to prepare for an upcoming release.
53+
- We checkout a pre-release branch to prepare for an upcoming release with the pattern `prerelease-0.1.xx`.
5454
- We perform additional manual and automated tests in this branch to make sure there are no regressions.
5555
- Once we are ready we tag the head of our release branch and perform a release on it.
5656
- Tagged releases are published as actions and they are the most suitable to be used in production.

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ inputs:
6464
description: Checkov version
6565
required: false
6666
default: '2.3.245'
67+
disable-locking:
68+
description: Disable locking
69+
required: false
70+
default: 'false'
6771

6872
outputs:
6973
output:
@@ -150,6 +154,7 @@ runs:
150154
env:
151155
PLAN_UPLOAD_DESTINATION: ${{ inputs.upload-plan-destination }}
152156
ACTIVATE_VENV: ${{ inputs.setup-checkov == 'true' }}
157+
DISABLE_LOCKING: ${{ inputs.disable-locking == 'true' }}
153158
run: |
154159
cd ${{ github.action_path }}
155160
go build -o digger ./cmd/digger
@@ -162,6 +167,7 @@ runs:
162167
env:
163168
actionref: ${{ github.action_ref }}
164169
PLAN_UPLOAD_DESTINATION: ${{ inputs.upload-plan-destination }}
170+
DISABLE_LOCKING: ${{ inputs.disable-locking == 'true' }}
165171
id: digger
166172
shell: bash
167173
run: |

go.mod

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ require (
66
cloud.google.com/go/storage v1.30.1
77
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0
88
github.com/Azure/azure-sdk-for-go/sdk/data/aztables v1.0.1
9-
github.com/aws/aws-sdk-go v1.44.266
9+
github.com/aws/aws-sdk-go v1.44.268
1010
github.com/bmatcuk/doublestar/v4 v4.6.0
1111
github.com/caarlos0/env/v7 v7.1.0
1212
github.com/google/go-github/v51 v51.0.0
1313
github.com/google/uuid v1.3.0
14-
github.com/stretchr/testify v1.8.3
15-
github.com/xanzy/go-gitlab v0.83.0
14+
github.com/stretchr/testify v1.8.4
15+
github.com/xanzy/go-gitlab v0.84.0
1616
gopkg.in/yaml.v3 v3.0.1
1717
)
1818

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8 h1:wPbRQzjjwF
2525
github.com/ProtonMail/go-crypto v0.0.0-20230217124315-7d5c6f04bbb8/go.mod h1:I0gYDMZ6Z5GRU7l58bNFSkPTFN6Yl12dsUlAZ8xy98g=
2626
github.com/aws/aws-sdk-go v1.44.266 h1:MWd775dcYf7NrwgcHLtlsIbWoWkX8p4vomfNHr88zH0=
2727
github.com/aws/aws-sdk-go v1.44.266/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
28+
github.com/aws/aws-sdk-go v1.44.268 h1:WoK20tlAvsvQzTcE6TajoprbXmTbcud6MjhErL4P/38=
29+
github.com/aws/aws-sdk-go v1.44.268/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
2830
github.com/bmatcuk/doublestar/v4 v4.6.0 h1:HTuxyug8GyFbRkrffIpzNCSK4luc0TY3wzXvzIZhEXc=
2931
github.com/bmatcuk/doublestar/v4 v4.6.0/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
3032
github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
@@ -116,8 +118,12 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
116118
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
117119
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
118120
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
121+
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
122+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
119123
github.com/xanzy/go-gitlab v0.83.0 h1:37p0MpTPNbsTMKX/JnmJtY8Ch1sFiJzVF342+RvZEGw=
120124
github.com/xanzy/go-gitlab v0.83.0/go.mod h1:5ryv+MnpZStBH8I/77HuQBsMbBGANtVpLWC15qOjWAw=
125+
github.com/xanzy/go-gitlab v0.84.0 h1:PdpCaskQSgcVDsx21c6ikf8Rfyo7SNtFAJwP9PrbCFE=
126+
github.com/xanzy/go-gitlab v0.84.0/go.mod h1:5ryv+MnpZStBH8I/77HuQBsMbBGANtVpLWC15qOjWAw=
121127
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
122128
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
123129
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=

pkg/utils/locking.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@ type Lock interface {
3636
GetLock(resource string) (*int, error)
3737
}
3838

39+
type NoOpLock struct {
40+
}
41+
42+
func (noOpLock *NoOpLock) Lock(transactionId int, resource string) (bool, error) {
43+
return true, nil
44+
}
45+
46+
func (noOpLock *NoOpLock) Unlock(resource string) (bool, error) {
47+
return true, nil
48+
}
49+
50+
func (noOpLock *NoOpLock) GetLock(resource string) (*int, error) {
51+
return nil, nil
52+
}
53+
3954
type ProjectLock interface {
4055
Lock(prNumber int) (bool, error)
4156
Unlock(prNumber int) (bool, error)
@@ -77,7 +92,9 @@ func (projectLock *ProjectLockImpl) Lock(prNumber int) (bool, error) {
7792
return false, err
7893
}
7994

80-
if lockAcquired {
95+
_, isNoOpLock := projectLock.InternalLock.(*NoOpLock)
96+
97+
if lockAcquired && !isNoOpLock {
8198
comment := "Project " + projectLock.projectId() + " has been locked by PR #" + strconv.Itoa(prNumber)
8299
projectLock.CIService.PublishComment(prNumber, comment)
83100
println("project " + projectLock.projectId() + " locked successfully. PR # " + strconv.Itoa(prNumber))
@@ -178,6 +195,11 @@ func GetLock() (Lock, error) {
178195
awsRegion := strings.ToLower(os.Getenv("AWS_REGION"))
179196
awsProfile := strings.ToLower(os.Getenv("AWS_PROFILE"))
180197
lockProvider := strings.ToLower(os.Getenv("LOCK_PROVIDER"))
198+
disableLocking := strings.ToLower(os.Getenv("DISABLE_LOCKING")) == "true"
199+
if disableLocking {
200+
log.Println("Using NoOp lock provider.")
201+
return &NoOpLock{}, nil
202+
}
181203
if lockProvider == "" || lockProvider == "aws" {
182204
log.Println("Using AWS lock provider.")
183205
sess, err := session.NewSessionWithOptions(session.Options{

0 commit comments

Comments
 (0)