Compare commits

...

75 commits

Author SHA1 Message Date
TP Honey
3a23b0d0d4
Merge pull request #3233 from alikhil/patch-1
Update links to discourse in issue template
2022-06-21 10:48:36 +01:00
Alik Khilazhev
9b89662825
chore(issue_template): update links to discourse 2022-06-21 12:36:37 +03:00
Eoin McAfee
1ac59bcac2
release prep for v2.12.1 (#3232)
* release prep for 2.12.1
2022-06-15 11:15:14 +01:00
Eoin McAfee
d7e34af1de
(bug) - fix original template scripts & remove amend scripts (#3229)
* removing amend template scripts and fixing original scripts due to Brads feedback
2022-06-15 09:11:28 +01:00
TP Honey
39e194ab11
Merge pull request #3230 from tphoney/starlark_windows_tests
(maint) fix starlark test on windows
2022-06-14 11:56:19 +01:00
TP Honey
2a70ce51cc (maint) fix starlark/jsonnet tests on windows 2022-06-14 11:47:36 +01:00
TP Honey
086c4b3f82
Merge pull request #3228 from tphoney/windows_unit_tests
(maint) fix unit tests so they pass on windows
2022-06-14 10:49:59 +01:00
Endymion Wight
b6053394ef
Added OAuth2 token refresher for Gitlab (#3215) 2022-06-14 10:46:35 +01:00
TP Honey
784c2e9e26 (maint) fix unit tests so they pass on windows 2022-06-13 17:46:57 +01:00
Eoin McAfee
f7a3c375a2
(bug) - remove unique index on template name (#3226)
* (bug) - remove unique index on template names
2022-06-09 14:30:18 +01:00
kit101
0fcf2536d2
Bump scm version to v1.24.0 (#3219)
* go-scm v1.24.0
2022-06-08 15:19:48 +01:00
Brad Rydzewski
0c764871d7
Merge pull request #3223 from hrittikhere/master [ci skip]
Update Readme to Fix Typo
2022-06-05 11:57:53 -04:00
Hrittik Roy
38dea1b91e Remove Typo for Readme.md 2022-06-04 17:08:05 +00:00
TP Honey
806833fe63
Merge pull request #3221 from harness/dron-239-template-comments
(bug) add unit test for comments in template file
2022-05-31 11:46:18 +01:00
Eoin McAfee
8cdafdf367 add unit test for comments in template file 2022-05-30 16:09:20 +01:00
TP Honey
95e091f093
Merge pull request #3214 from tphoney/prep_v2.12.0
release prep v2.12.0
2022-05-16 10:05:14 +01:00
TP Honey
aa18fc5322 release prep v2.12.0 2022-05-13 11:52:09 +01:00
TP Honey
724bd35cfc
Merge pull request #3210 from tphoney/dron-267
(dron-267) correctly set parent for promotion retry
2022-05-09 15:33:59 +01:00
TP Honey
046ad743e8
Merge pull request #3211 from tphoney/drone-ui_2.8.2
(fix) update drone ui to 2.8.2
2022-05-09 14:39:37 +01:00
TP Honey
12a70ea9a3 (fix) update drone ui to 2.8.2 2022-05-09 14:34:22 +01:00
TP Honey
eb26c8bce7 (dron-267) correctly set parent for promotion retry 2022-05-09 11:11:54 +01:00
Brad Rydzewski
6fb7bb00cc
Merge pull request #3208 from dnielsen/patch-1 [ci skip]
fixing URL
2022-04-28 10:48:17 -04:00
Dave Nielsen
0c3ef97409
fixing URL
changed URL from https://github.com/drone/drone to https://github.com/harness/drone
2022-04-28 02:21:02 -07:00
Dan Wilson
f5d9c05374
Merge pull request #3204 from harness/bump-go-scm-version
bump SCM version to v1.21.1
2022-04-22 15:18:53 +01:00
Dan Wilson
f4bb0f5797 bump SCM version to v1.21.1 2022-04-22 15:10:49 +01:00
Dan Wilson
8cbca28127
Merge pull request #3202 from harness/bump-ui-version
bump ui version
2022-04-14 11:48:19 +01:00
Dan Wilson
3aa920bae0 bump ui version 2022-04-14 11:41:43 +01:00
Marie Antons
65a367fa39
Merge pull request #3199 from harness/update-community-information
update community information with updated links
2022-04-05 08:33:53 -04:00
Marie
97afdfa7d7 update community information with updated links 2022-04-04 09:22:00 -03:00
Brad Rydzewski
1de855eb61 remove default from DRONE_CONVERT_MULTI 2022-03-17 16:12:53 -07:00
Brad Rydzewski
62f1086680 feature flag to allow multiple conversion extensions 2022-03-17 14:51:48 -07:00
Brad Rydzewski
7b42cd9bbd add user token to extension payload 2022-03-16 09:37:25 -07:00
TP Honey
6a81c655ff
Merge pull request #3197 from harness/prep-v2.11.1
(maint) release prep for 2.11.1
2022-03-15 15:12:12 +00:00
Dan Wilson
a4995ca7f3 (maint) release prep for 2.11.1 2022-03-15 15:03:45 +00:00
Dan Wilson
f9627f8e40
Merge pull request #3196 from harness/dron-246-ignore-nil-repos-in-list
ignore nil repos in list and add better debugging
2022-03-14 13:34:13 +00:00
Dan Wilson
dc6c94b7af clean up debug code 2022-03-14 13:22:54 +00:00
Dan Wilson
80629d12fa ignore nil repos in list and add better debugging 2022-03-14 12:17:55 +00:00
Dan Wilson
e3c598109b
Merge pull request #3194 from harness/prep-v2.11.0
(maint) release prep for 2.11.0
2022-03-08 17:12:19 +00:00
Dan Wilson
3e52b2f4ed (maint) release prep for 2.11.0 2022-03-08 17:03:37 +00:00
Dan Wilson
3f6096325b
Merge pull request #3193 from harness/bump-ui-scm-version
bump UI and SCM versions
2022-03-08 16:56:56 +00:00
Dan Wilson
359cefc2a7 bump UI and SCM versions 2022-03-08 16:49:21 +00:00
Dan Wilson
be2660aac9
Merge pull request #3191 from harness/prep-v2.10.0
(maint) release prep for 2.10.0
2022-03-03 14:12:05 +00:00
Dan Wilson
e909c5f7d8 (maint) release prep for 2.10.0 2022-03-03 13:55:49 +00:00
Dan Wilson
c7b8403a7c
Merge pull request #3190 from harness/bump-ui-version
bump UI version to v2.7.0
2022-03-03 11:57:39 +00:00
Dan Wilson
a6c0937cc3 bump UI version to v2.7.0 2022-03-03 11:48:30 +00:00
Dan Wilson
9fb00fc478
Merge pull request #3188 from harness/bump-ui-version
bump UI version to v2.6.2
2022-02-15 14:12:59 +00:00
Dan Wilson
67cb161eaf bump ui version 2022-02-15 12:03:43 +00:00
TP Honey
bb9844ab3c
Merge pull request #3186 from harness/prep-v2.9.1
(maint) release prep for 2.9.1
2022-01-27 11:20:16 +00:00
TP Honey
12c83861eb (maint) release prep for 2.9.1 2022-01-27 11:08:43 +00:00
TP Honey
a687caacbb
Merge pull request #3185 from harness/bump-ui-version
bump ui version 2.6.1
2022-01-27 10:46:12 +00:00
Dan Wilson
9a3dfe318c bump ui version 2022-01-27 10:35:56 +00:00
Dan Wilson
1f61646ba8
Merge pull request #3184 from harness/v2.9.0
release prep for v2.9.0
2022-01-26 16:19:23 +00:00
Eoin McAfee
987683c723 release prep for v2.9.0 2022-01-26 16:04:14 +00:00
Eoin McAfee
c2104a18f0
bump ui to v2.6.0 (#3183) 2022-01-25 16:59:55 +00:00
Eoin McAfee
07731e4df8
release prep v2.8.0 (#3181) 2022-01-11 11:59:20 +00:00
Eoin McAfee
3088c670ae
bump UI to v2.5.0 (#3180) 2022-01-11 11:43:24 +00:00
Michelangelo
f889ae8eb0
Add tag filter when call build list endpoint (#3173)
* Add tag filter when call build list endpoint

* Add unit test
2022-01-11 11:03:41 +00:00
TP Honey
0aca433670
Merge pull request #3179 from tphoney/comment_on_step
(maint) add warning around typo for stage_id in step struct
2022-01-11 10:45:14 +00:00
TP Honey
cee773ac6a (maint) add warning around typo for stage_id in step struct 2022-01-11 10:39:57 +00:00
Eoin McAfee
7e757c4a3d
(feat) ignore archive repos on sync (#3178)
* (feat) ignore archive repos on sync
2022-01-10 10:49:37 +00:00
TP Honey
3398f2eb57
Merge pull request #3174 from kit101/add-datadog-tag
Datadog add the tag of 'remote:gitee'
2022-01-04 10:27:14 +00:00
Eoin McAfee
62be60f9ac
release prep v2.7.3 (#3176) 2021-12-30 13:54:42 +00:00
Eoin McAfee
979c06957a
bump go-scm to v1.16.3 (#3175) 2021-12-30 13:37:00 +00:00
kit101
fab2899a2b Datadog add the tag of 'remote:gitee' 2021-12-27 08:44:19 +08:00
Eoin McAfee
f51eb4ed22
release prep 2.7.2 (#3172) 2021-12-19 13:02:58 +00:00
kit101
c9c1f82c7a
fixbug gitee provide refresher (#3168) 2021-12-19 12:45:19 +00:00
kit101
cb6fb442cd
bump go-scm to v1.16.2 (#3169) 2021-12-19 12:45:05 +00:00
Eoin McAfee
92f6f66c33
release prep v2.7.1 (#3171)
* release prep

* revert back go.sum
2021-12-17 15:12:36 +00:00
Eoin McAfee
ee99e86b2c
removed redirect slashes and changed to stripslashses (#3170) 2021-12-17 14:36:36 +00:00
TP Honey
f67ec3cc50
Merge pull request #3166 from harness/release/v2.7.0
release v2.7.0
2021-12-15 15:23:06 +00:00
Dan Wilson
abe1824354 release v2.7.0
update changelog
2021-12-15 15:16:47 +00:00
Dan Wilson
50c8911f2a
Merge pull request #3167 from harness/bump-ui-version
bump UI to v2.4.1
2021-12-15 14:30:28 +00:00
Dan Wilson
64a7e8f92a bump UI to v2.4.1 2021-12-15 14:21:51 +00:00
TP Honey
996353bfff
Merge pull request #3165 from tphoney/DRON-157
(DRON-157) use deploy string in deployment
2021-12-14 13:08:18 +00:00
TP Honey
8de5eac502 (DRON-157) use deploy string in deployment 2021-12-08 11:59:51 +00:00
44 changed files with 632 additions and 57 deletions

View file

@ -4,9 +4,9 @@ Bugs or Issues? Please create a new topic in our Discourse forum.
We are migrating all Drone repositories to Discourse for bug tracking.
New GitHub issues may be automatically deleted.
https://discourse.drone.io/
https://discourse.drone.io/c/bugs
https://discourse.drone.io/c/ideas
https://community.harness.io/
https://community.harness.io/c/bugs/17
https://community.harness.io/c/ideas/11
Failing Builds? Please do not use GitHub issues for generic support
questions. Instead please use Stack Overflow:

17
.github/readme.md vendored
View file

@ -8,7 +8,7 @@ Drone is a continuous delivery system built on container technology. Drone uses
- [What is Drone?](#what-is-drone)
- [Table of Contents](#table-of-contents)
- [Community](#community)
- [Community and Support](#community-and-support)
- [Contributing](#contributing)
- [Code of Conduct](#code-of-conduct)
- [Setup Documentation](#setup-documentation)
@ -17,13 +17,18 @@ Drone is a continuous delivery system built on container technology. Drone uses
- [Plugin Index](#plugin-index)
- [Documentation and Other Links](#documentation-and-Other-Links)
## Community
You can visit us at [Discourse](https://discourse.drone.io/) as well as our [Slack](https://join.slack.com/t/harnesscommunity/shared_invite/zt-90wb0w6u-OATJvUBkSDR3W9oYX7D~4A).
## Community and Support
[Harness Community Slack](https://join.slack.com/t/harnesscommunity/shared_invite/zt-y4hdqh7p-RVuEQyIl5Hcx4Ck8VCvzBw) - Join the #drone slack channel to connect with our engineers and other users running Drone CI.
</br>
[Harness Community Forum](https://community.harness.io/) - Ask questions, find answers, and help other users.
</br>
[Report A Bug](https://community.harness.io/c/bugs/17) - Find a bug? Please report in our forum under Drone Bugs. Please provide screenshots and steps to reproduce.
</br>
[Events](https://www.meetup.com/harness/) - Keep up to date with Drone events and check out previous events [here](https://www.youtube.com/watch?v=Oq34ImUGcHA&list=PLXsYHFsLmqf3zwelQDAKoVNmLeqcVsD9o).
## Contributing
We encourage you to contribute to Drone! whether thats joining in on the community slack or discourse, or contributing pull requests / documentation changes or raising issues.
We encourage you to contribute to Drone! Whether that's joining in on the community slack or discourse, or contributing pull requests / documentation changes or raising issues.
## Code of Conduct
@ -102,7 +107,7 @@ docker run -it --rm -v "$(pwd)":/usr/local/src/your-app githubchangeloggenerator
You can generate a token by logging into your GitHub account and going to Settings -> Personal access tokens.
Next we tag the PR's with the fixes or enhancements labels. If the PR does not fufil the requirements, do not add a label.
Next we tag the PR's with the fixes or enhancements labels. If the PR does not fulfill the requirements, do not add a label.
**Before moving on make sure to update the version file `version/version.go && version/version_test.go`.**

View file

@ -1,2 +1,3 @@
since-tag=v2.0.4
issues=false

View file

@ -1,5 +1,179 @@
# Changelog
## [v2.12.1](https://github.com/harness/drone/tree/v2.12.1) (2022-06-15)
[Full Changelog](https://github.com/harness/drone/compare/v2.12.0...v2.12.1)
**Fixed bugs:**
- \(bug\) - fix original template scripts & remove amend scripts [\#3229](https://github.com/harness/drone/pull/3229) ([eoinmcafee00](https://github.com/eoinmcafee00))
- \(bug\) - remove unique index on template name [\#3226](https://github.com/harness/drone/pull/3226) ([eoinmcafee00](https://github.com/eoinmcafee00))
- Added OAuth2 token refresher for Gitlab [\#3215](https://github.com/harness/drone/pull/3215) ([EndymionWight](https://github.com/EndymionWight))
**Merged pull requests:**
- \(maint\) fix starlark test on windows [\#3230](https://github.com/harness/drone/pull/3230) ([tphoney](https://github.com/tphoney))
- \(maint\) fix unit tests so they pass on windows [\#3228](https://github.com/harness/drone/pull/3228) ([tphoney](https://github.com/tphoney))
- Update Readme to Fix Typo [\#3223](https://github.com/harness/drone/pull/3223) ([hrittikhere](https://github.com/hrittikhere))
- \(bug\) add unit test for comments in template file [\#3221](https://github.com/harness/drone/pull/3221) ([eoinmcafee00](https://github.com/eoinmcafee00))
- Bump scm version to v1.24.0 [\#3219](https://github.com/harness/drone/pull/3219) ([kit101](https://github.com/kit101))
## [v2.12.0](https://github.com/harness/drone/tree/v2.12.0) (2022-05-16)
[Full Changelog](https://github.com/harness/drone/compare/v2.11.1...v2.12.0)
**Implemented enhancements:**
- bump SCM version to v1.21.1 [\#3204](https://github.com/harness/drone/pull/3204) ([d1wilko](https://github.com/d1wilko))
- bump ui version [\#3202](https://github.com/harness/drone/pull/3202) ([d1wilko](https://github.com/d1wilko))
**Fixed bugs:**
- \(fix\) update drone ui to 2.8.2 [\#3211](https://github.com/harness/drone/pull/3211) ([tphoney](https://github.com/tphoney))
- \(dron-267\) correctly set parent for promotion retry [\#3210](https://github.com/harness/drone/pull/3210) ([tphoney](https://github.com/tphoney))
**Merged pull requests:**
- release prep v2.12.0 [\#3214](https://github.com/harness/drone/pull/3214) ([tphoney](https://github.com/tphoney))
- fixing URL [\#3208](https://github.com/harness/drone/pull/3208) ([dnielsen](https://github.com/dnielsen))
- update community information with updated links [\#3199](https://github.com/harness/drone/pull/3199) ([mrsantons](https://github.com/mrsantons))
## [v2.11.1](https://github.com/harness/drone/tree/v2.11.1) (2022-03-15)
[Full Changelog](https://github.com/harness/drone/compare/v2.11.0...v2.11.1)
**Fixed bugs:**
- ignore nil repos in list and add better debugging [\#3196](https://github.com/harness/drone/pull/3196) ([d1wilko](https://github.com/d1wilko))
**Merged pull requests:**
- \(maint\) release prep for 2.11.1 [\#3197](https://github.com/harness/drone/pull/3197) ([d1wilko](https://github.com/d1wilko))
## [v2.11.0](https://github.com/harness/drone/tree/v2.11.0) (2022-03-08)
[Full Changelog](https://github.com/harness/drone/compare/v2.10.0...v2.11.0)
**Implemented enhancements:**
- bump UI and SCM versions [\#3193](https://github.com/harness/drone/pull/3193) ([d1wilko](https://github.com/d1wilko))
**Merged pull requests:**
- \(maint\) release prep for 2.11.0 [\#3194](https://github.com/harness/drone/pull/3194) ([d1wilko](https://github.com/d1wilko))
## [v2.10.0](https://github.com/harness/drone/tree/v2.10.0) (2022-03-03)
[Full Changelog](https://github.com/harness/drone/compare/v2.9.1...v2.10.0)
**Implemented enhancements:**
- bump UI version to v2.7.0 [\#3190](https://github.com/harness/drone/pull/3190) ([d1wilko](https://github.com/d1wilko))
- bump UI version to v2.6.2 [\#3188](https://github.com/harness/drone/pull/3188) ([d1wilko](https://github.com/d1wilko))
**Merged pull requests:**
- \(maint\) release prep for 2.10.0 [\#3191](https://github.com/harness/drone/pull/3191) ([d1wilko](https://github.com/d1wilko))
## [v2.9.1](https://github.com/harness/drone/tree/v2.9.1) (2022-01-27)
[Full Changelog](https://github.com/harness/drone/compare/v2.9.0...v2.9.1)
**Fixed bugs:**
- bump ui version 2.6.1 [\#3185](https://github.com/harness/drone/pull/3185) ([d1wilko](https://github.com/d1wilko))
**Merged pull requests:**
- \(maint\) release prep for 2.9.1 [\#3186](https://github.com/harness/drone/pull/3186) ([tphoney](https://github.com/tphoney))
## [v2.9.0](https://github.com/harness/drone/tree/v2.9.0) (2022-01-26)
[Full Changelog](https://github.com/harness/drone/compare/v2.8.0...v2.9.0)
**Implemented enhancements:**
- bump ui to v2.6.0 [\#3183](https://github.com/harness/drone/pull/3183) ([eoinmcafee00](https://github.com/eoinmcafee00))
**Merged pull requests:**
- release prep for v2.9.0 [\#3184](https://github.com/harness/drone/pull/3184) ([eoinmcafee00](https://github.com/eoinmcafee00))
## [v2.8.0](https://github.com/harness/drone/tree/v2.8.0) (2022-01-11)
[Full Changelog](https://github.com/harness/drone/compare/v2.7.3...v2.8.0)
**Implemented enhancements:**
- bump UI to v2.5.0 [\#3180](https://github.com/harness/drone/pull/3180) ([eoinmcafee00](https://github.com/eoinmcafee00))
- \(feat\) ignore archive repos on sync [\#3178](https://github.com/harness/drone/pull/3178) ([eoinmcafee00](https://github.com/eoinmcafee00))
- Datadog add the tag of 'remote:gitee' [\#3174](https://github.com/harness/drone/pull/3174) ([kit101](https://github.com/kit101))
- Add tag filter when call build list endpoint [\#3173](https://github.com/harness/drone/pull/3173) ([michelangelomo](https://github.com/michelangelomo))
**Fixed bugs:**
- \(maint\) add warning around typo for stage\_id in step struct [\#3179](https://github.com/harness/drone/pull/3179) ([tphoney](https://github.com/tphoney))
**Merged pull requests:**
- release prep v2.8.0 [\#3181](https://github.com/harness/drone/pull/3181) ([eoinmcafee00](https://github.com/eoinmcafee00))
## [v2.7.3](https://github.com/harness/drone/tree/v2.7.3) (2021-12-30)
[Full Changelog](https://github.com/harness/drone/compare/v2.7.2...v2.7.3)
**Fixed bugs:**
- bump go-scm to v1.16.3 [\#3175](https://github.com/harness/drone/pull/3175) ([eoinmcafee00](https://github.com/eoinmcafee00))
**Merged pull requests:**
- release prep v2.7.3 [\#3176](https://github.com/harness/drone/pull/3176) ([eoinmcafee00](https://github.com/eoinmcafee00))
## [v2.7.2](https://github.com/harness/drone/tree/v2.7.2) (2021-12-19)
[Full Changelog](https://github.com/harness/drone/compare/v2.7.1...v2.7.2)
**Implemented enhancements:**
- bump go-scm to v1.16.2 [\#3169](https://github.com/harness/drone/pull/3169) ([kit101](https://github.com/kit101))
**Fixed bugs:**
- fixbug gitee provide refresher [\#3168](https://github.com/harness/drone/pull/3168) ([kit101](https://github.com/kit101))
**Merged pull requests:**
- release prep 2.7.2 [\#3172](https://github.com/harness/drone/pull/3172) ([eoinmcafee00](https://github.com/eoinmcafee00))
## [v2.7.1](https://github.com/harness/drone/tree/v2.7.1) (2021-12-17)
[Full Changelog](https://github.com/harness/drone/compare/v2.7.0...v2.7.1)
**Fixed bugs:**
- fixes issue with redirects on double slashes in url [\#3170](https://github.com/harness/drone/pull/3170) ([eoinmcafee00](https://github.com/eoinmcafee00))
**Merged pull requests:**
- release prep v2.7.1 [\#3171](https://github.com/harness/drone/pull/3171) ([eoinmcafee00](https://github.com/eoinmcafee00))
## [v2.7.0](https://github.com/harness/drone/tree/v2.7.0) (2021-12-15)
[Full Changelog](https://github.com/harness/drone/compare/v2.6.0...v2.7.0)
**Implemented enhancements:**
- bump UI to v2.4.1 [\#3167](https://github.com/harness/drone/pull/3167) ([d1wilko](https://github.com/d1wilko))
**Fixed bugs:**
- \(DRON-157\) use deploy string in deployment [\#3165](https://github.com/harness/drone/pull/3165) ([tphoney](https://github.com/tphoney))
**Merged pull requests:**
- release v2.7.0 [\#3166](https://github.com/harness/drone/pull/3166) ([d1wilko](https://github.com/d1wilko))
## [v2.6.0](https://github.com/harness/drone/tree/v2.6.0) (2021-11-30)
[Full Changelog](https://github.com/harness/drone/compare/v2.5.0...v2.6.0)
@ -8,6 +182,10 @@
- Feat: implemented gitee client [\#3156](https://github.com/harness/drone/pull/3156) ([kit101](https://github.com/kit101))
**Merged pull requests:**
- release prep for v2.6.0 [\#3163](https://github.com/harness/drone/pull/3163) ([tphoney](https://github.com/tphoney))
## [v2.5.0](https://github.com/harness/drone/tree/v2.5.0) (2021-11-17)
[Full Changelog](https://github.com/harness/drone/compare/v2.4.0...v2.5.0)

View file

@ -21,7 +21,7 @@ Drone Non-Commercial License
Contributor: Drone.IO, Inc.
Source Code: https://github.com/drone/drone
Source Code: https://github.com/harness/drone
This license lets you use and share this software for free,
with a trial-length time limit on commercial use. Specifically:

View file

@ -320,6 +320,10 @@ type (
SkipVerify bool `envconfig:"DRONE_CONVERT_PLUGIN_SKIP_VERIFY"`
CacheSize int `envconfig:"DRONE_CONVERT_PLUGIN_CACHE_SIZE" default:"10"`
Timeout time.Duration `envconfig:"DRONE_CONVERT_TIMEOUT" default:"1m"`
// this flag can be removed once we solve for
// https://github.com/harness/drone/pull/2994#issuecomment-795955312
Multi bool `envconfig:"DRONE_CONVERT_MULTI"`
}
// Validate provides the validation webhook configuration.
@ -489,6 +493,12 @@ func (c *Config) IsGitea() bool {
return c.Gitea.Server != ""
}
// IsGitee returns true if the Gitee integration
// is activated.
func (c *Config) IsGitee() bool {
return c.Gitee.ClientID != ""
}
// IsBitbucket returns true if the Bitbucket Cloud
// integration is activated.
func (c *Config) IsBitbucket() bool {

View file

@ -123,8 +123,14 @@ func provideGiteeClient(config config.Config) *scm.Client {
}
client.Client = &http.Client{
Transport: &oauth2.Transport{
Source: oauth2.ContextTokenSource(),
Base: defaultTransport(config.Gitee.SkipVerify),
Scheme: oauth2.SchemeBearer,
Source: &oauth2.Refresher{
ClientID: config.Gitee.ClientID,
ClientSecret: config.Gitee.ClientSecret,
Endpoint: strings.TrimSuffix(config.Gitee.Server, "/") + "/oauth/token",
Source: oauth2.ContextTokenSource(),
},
Base: defaultTransport(config.Gitee.SkipVerify),
},
}
return client
@ -174,7 +180,13 @@ func provideGitlabClient(config config.Config) *scm.Client {
}
client.Client = &http.Client{
Transport: &oauth2.Transport{
Source: oauth2.ContextTokenSource(),
Scheme: oauth2.SchemeBearer,
Source: &oauth2.Refresher{
ClientID: config.GitLab.ClientID,
ClientSecret: config.GitLab.ClientSecret,
Endpoint: strings.TrimSuffix(config.GitLab.Server, "/") + "/oauth/token",
Source: oauth2.ContextTokenSource(),
},
Base: defaultTransport(config.GitLab.SkipVerify),
},
}

View file

@ -116,7 +116,7 @@ func provideGiteaLogin(config config.Config) login.Middleware {
if config.Gitea.Server == "" {
return nil
}
return &gitea.Config {
return &gitea.Config{
ClientID: config.Gitea.ClientID,
ClientSecret: config.Gitea.ClientSecret,
Server: config.Gitea.Server,
@ -197,6 +197,23 @@ func provideRefresher(config config.Config) *oauth2.Refresher {
Source: oauth2.ContextTokenSource(),
Client: defaultClient(config.Gitea.SkipVerify),
}
case config.GitLab.ClientID != "":
return &oauth2.Refresher{
ClientID: config.GitLab.ClientID,
ClientSecret: config.GitLab.ClientSecret,
Endpoint: strings.TrimSuffix(config.GitLab.Server, "/") + "/oauth/token",
Source: oauth2.ContextTokenSource(),
Client: defaultClient(config.GitLab.SkipVerify),
}
case config.Gitee.ClientID != "":
return &oauth2.Refresher{
ClientID: config.Gitee.ClientID,
ClientSecret: config.Gitee.ClientSecret,
Endpoint: strings.TrimSuffix(config.Gitee.Server, "/") + "/oauth/token",
Source: oauth2.ContextTokenSource(),
Client: defaultClient(config.Gitee.SkipVerify),
}
}
return nil
}

View file

@ -78,6 +78,7 @@ func provideConfigPlugin(client *scm.Client, contents core.FileService, conf spe
// configuration.
func provideConvertPlugin(client *scm.Client, fileService core.FileService, conf spec.Config, templateStore core.TemplateStore) core.ConvertService {
return converter.Combine(
conf.Convert.Multi,
converter.Legacy(false),
converter.Starlark(
conf.Starlark.Enabled,

View file

@ -212,6 +212,7 @@ func provideDatadog(
EnableStash: config.IsStash(),
EnableGogs: config.IsGogs(),
EnableGitea: config.IsGitea(),
EnableGitee: config.IsGitee(),
EnableAgents: !config.Agent.Disabled,
},
)

View file

@ -65,6 +65,7 @@ type (
Secret string `json:"-"`
Build *Build `json:"build,omitempty"`
Perms *Perm `json:"permissions,omitempty"`
Archived bool `json:"archived"`
}
RepoBuildStage struct {

View file

@ -20,7 +20,7 @@ type (
// Step represents an individual step in the stage.
Step struct {
ID int64 `json:"id"`
StageID int64 `json:"step_id"`
StageID int64 `json:"step_id"` // this is a typo, fixing it has far reaching ramifications. It should only be attempted in a major version change
Number int `json:"number"`
Name string `json:"name"`
Status string `json:"status"`

6
go.mod
View file

@ -12,15 +12,15 @@ require (
github.com/coreos/go-semver v0.2.0
github.com/dchest/authcookie v0.0.0-20120917135355-fbdef6e99866
github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9
github.com/drone/drone-go v1.4.1-0.20201109202657-b9e58bbbcf27
github.com/drone/drone-go v1.7.2-0.20220308165842-f9e4fe31c2af
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d
github.com/drone/drone-ui v2.4.0+incompatible
github.com/drone/drone-ui v2.8.2+incompatible
github.com/drone/drone-yaml v1.2.4-0.20200326192514-6f4d6dfb39e4
github.com/drone/envsubst v1.0.3-0.20200709231038-aa43e1c1a629
github.com/drone/funcmap v0.0.0-20210823160631-9e9dec149056
github.com/drone/go-license v1.0.2
github.com/drone/go-login v1.1.0
github.com/drone/go-scm v1.16.1
github.com/drone/go-scm v1.24.0
github.com/drone/signal v1.0.0
github.com/dustin/go-humanize v1.0.0
github.com/go-chi/chi v3.3.3+incompatible

14
go.sum
View file

@ -73,15 +73,13 @@ github.com/docker/go-connections v0.3.0 h1:3lOnM9cSzgGwx8VfK/NGOW5fLQ0GjIlCkaktF
github.com/docker/go-connections v0.3.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.3.3 h1:Xk8S3Xj5sLGlG5g67hJmYMmUgXv5N4PhkjJHHqrwnTk=
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/drone/drone-go v1.4.1-0.20201109202657-b9e58bbbcf27 h1:58xKlW/Kwp/Apz+R5qNGzBUIzfq1Z57L7Udz1B6bgWE=
github.com/drone/drone-go v1.4.1-0.20201109202657-b9e58bbbcf27/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRpTZ1mXg=
github.com/drone/drone-go v1.7.2-0.20220308165842-f9e4fe31c2af h1:I+xfWPZLMaskFvfFO5fEJ6tVI1Q9bWR9tuORZeaCTPo=
github.com/drone/drone-go v1.7.2-0.20220308165842-f9e4fe31c2af/go.mod h1:fxCf9jAnXDZV1yDr0ckTuWd1intvcQwfJmTRpTZ1mXg=
github.com/drone/drone-runtime v1.0.7-0.20190729202838-87c84080f4a1/go.mod h1:+osgwGADc/nyl40J0fdsf8Z09bgcBZXvXXnLOY48zYs=
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d h1:P5HI/Y9hARTZ3F3EKs0kYijhjXZWQRQHYn1neTi0pWM=
github.com/drone/drone-runtime v1.1.1-0.20200623162453-61e33e2cab5d/go.mod h1:4/2QToW5+HGD0y1sTw7X35W1f7YINS14UfDY4isggT8=
github.com/drone/drone-ui v2.3.1+incompatible h1:JYOer5JRttNjXGJhJnH/ELksr3ORO/OWZS19VdlGtro=
github.com/drone/drone-ui v2.3.1+incompatible/go.mod h1:NBtVWW7NNJpD9+huMD/5TAE1db2nrEh0i35/9Rf1MPI=
github.com/drone/drone-ui v2.4.0+incompatible h1:AEuauuZRe8n2vj97/QWCugBEnUOkV/iVVaUYR1ipiQ4=
github.com/drone/drone-ui v2.4.0+incompatible/go.mod h1:NBtVWW7NNJpD9+huMD/5TAE1db2nrEh0i35/9Rf1MPI=
github.com/drone/drone-ui v2.8.2+incompatible h1:7F/MlcSEIZVi5VND/qmOnDDwQOkgqwsCVOQOsGJ2HJc=
github.com/drone/drone-ui v2.8.2+incompatible/go.mod h1:NBtVWW7NNJpD9+huMD/5TAE1db2nrEh0i35/9Rf1MPI=
github.com/drone/drone-yaml v1.2.4-0.20200326192514-6f4d6dfb39e4 h1:XsstoCeXC2t8lA9OLTdoFwckaptqahxwjCWsenySfX8=
github.com/drone/drone-yaml v1.2.4-0.20200326192514-6f4d6dfb39e4/go.mod h1:QsqliFK8nG04AHFN9tTn9XJomRBQHD4wcejWW1uz/10=
github.com/drone/envsubst v1.0.3-0.20200709231038-aa43e1c1a629 h1:rIaZZalMGGPb2cU/+ypuggZ8aMlpa17RUlJUtsMv8pw=
@ -92,8 +90,8 @@ github.com/drone/go-license v1.0.2 h1:7OwndfYk+Lp/cGHkxe4HUn/Ysrrw3WYH2pnd99yrko
github.com/drone/go-license v1.0.2/go.mod h1:fGRHf+F1cEaw3YVYiJ6js3G3dVhcxyS617RnNRUMsms=
github.com/drone/go-login v1.1.0 h1:anQFRh2Z5ketEJ/LvL6SJ6rIwDdfysGXK5bSXkFLInI=
github.com/drone/go-login v1.1.0/go.mod h1:FLxy9vRzLbyBxoCJYxGbG9R0WGn6OyuvBmAtYNt43uw=
github.com/drone/go-scm v1.16.1 h1:OuCJ/d9iUzxSDqryOn5EW2sdOK92gSSMLhMe9Vf+r3c=
github.com/drone/go-scm v1.16.1/go.mod h1:DFIJJjhMj0TSXPz+0ni4nyZ9gtTtC40Vh/TGRugtyWw=
github.com/drone/go-scm v1.24.0 h1:wE6bP9gnuyyKJStnl6wl0npt/SBQumjE9jilQAcFy6Q=
github.com/drone/go-scm v1.24.0/go.mod h1:DFIJJjhMj0TSXPz+0ni4nyZ9gtTtC40Vh/TGRugtyWw=
github.com/drone/signal v1.0.0 h1:NrnM2M/4yAuU/tXs6RP1a1ZfxnaHwYkd0kJurA1p6uI=
github.com/drone/signal v1.0.0/go.mod h1:S8t92eFT0g4WUgEc/LxG+LCuiskpMNsG0ajAMGnyZpc=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=

View file

@ -37,6 +37,7 @@ func HandleList(
namespace = chi.URLParam(r, "owner")
name = chi.URLParam(r, "name")
branch = r.FormValue("branch")
tag = r.FormValue("tag")
page = r.FormValue("page")
perPage = r.FormValue("per_page")
)
@ -66,6 +67,9 @@ func HandleList(
if branch != "" {
ref := fmt.Sprintf("refs/heads/%s", branch)
results, err = builds.ListRef(r.Context(), repo.ID, ref, limit, offset)
} else if tag != "" {
ref := fmt.Sprintf("refs/tags/%s", tag)
results, err = builds.ListRef(r.Context(), repo.ID, ref, limit, offset)
} else {
results, err = builds.List(r.Context(), repo.ID, limit, offset)
}

View file

@ -139,6 +139,38 @@ func TestListBranch(t *testing.T) {
}
}
func TestListTag(t *testing.T) {
controller := gomock.NewController(t)
defer controller.Finish()
repos := mock.NewMockRepositoryStore(controller)
repos.EXPECT().FindName(gomock.Any(), gomock.Any(), mockRepo.Name).Return(mockRepo, nil)
builds := mock.NewMockBuildStore(controller)
builds.EXPECT().ListRef(gomock.Any(), mockRepo.ID, "refs/tags/1.33.7", 25, 0).Return(mockBuilds, nil)
c := new(chi.Context)
c.URLParams.Add("owner", "octocat")
c.URLParams.Add("name", "hello-world")
w := httptest.NewRecorder()
r := httptest.NewRequest("GET", "/?tag=1.33.7", nil)
r = r.WithContext(
context.WithValue(context.Background(), chi.RouteCtxKey, c),
)
HandleList(repos, builds)(w, r)
if got, want := w.Code, 200; want != got {
t.Errorf("Want response code %d, got %d", want, got)
}
got, want := []*core.Build{}, mockBuilds
json.NewDecoder(w.Body).Decode(&got)
if diff := cmp.Diff(got, want); len(diff) != 0 {
t.Errorf(diff)
}
}
func TestList_RepositoryNotFound(t *testing.T) {
controller := gomock.NewController(t)
defer controller.Finish()

View file

@ -64,6 +64,7 @@ func HandleRetry(
}
hook := &core.Hook{
Parent: prev.Number,
Trigger: user.Login,
Event: prev.Event,
Action: prev.Action,

View file

@ -97,7 +97,7 @@ func (s Server) Handler() http.Handler {
r.Use(middleware.Recoverer)
r.Use(middleware.NoCache)
r.Use(logger.Middleware)
r.Use(middleware.RedirectSlashes)
r.Use(middleware.StripSlashes)
sec := secure.New(s.Options)
r.Use(sec.Handler)

View file

@ -29,5 +29,6 @@ type Config struct {
EnableStash bool
EnableGogs bool
EnableGitea bool
EnableGitee bool
EnableAgents bool
}

View file

@ -42,6 +42,8 @@ func createTags(config Config) []string {
tags = append(tags, "remote:gogs")
case config.EnableGitea:
tags = append(tags, "remote:gitea")
case config.EnableGitee:
tags = append(tags, "remote:gitee")
default:
tags = append(tags, "remote:undefined")
}

View file

@ -797,3 +797,19 @@ func (mr *MockUserServiceMockRecorder) FindLogin(arg0, arg1 interface{}) *gomock
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindLogin", reflect.TypeOf((*MockUserService)(nil).FindLogin), arg0, arg1)
}
// ListEmail mocks base method
func (m *MockUserService) ListEmail(arg0 context.Context, arg1 scm.ListOptions) ([]*scm.Email, *scm.Response, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ListEmail", arg0, arg1)
ret0, _ := ret[0].([]*scm.Email)
ret1, _ := ret[1].(*scm.Response)
ret2, _ := ret[2].(error)
return ret0, ret1, ret2
}
// ListEmail indicates an expected call of ListEmail.
func (mr *MockUserServiceMockRecorder) ListEmail(arg0, arg1 interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ListEmail", reflect.TypeOf((*MockUserService)(nil).ListEmail), arg0, arg1)
}

View file

@ -2,6 +2,7 @@
// Use of this source code is governed by the Drone Non-Commercial License
// that can be found in the LICENSE file.
//go:build !oss
// +build !oss
package config
@ -33,7 +34,7 @@ func Global(endpoint, signer string, skipVerify bool, timeout time.Duration) cor
}
type global struct {
client config.Plugin
client config.Plugin
timeout time.Duration
}
@ -51,6 +52,10 @@ func (g *global) Find(ctx context.Context, in *core.ConfigArgs) (*core.Config, e
req := &config.Request{
Repo: toRepo(in.Repo),
Build: toBuild(in.Build),
Token: drone.Token{
Access: in.User.Token,
Refresh: in.User.Refresh,
},
}
res, err := g.client.Find(ctx, req)

View file

@ -22,12 +22,16 @@ import (
// Combine combines the conversion services, provision support
// for multiple conversion utilities.
func Combine(services ...core.ConvertService) core.ConvertService {
return &combined{services}
func Combine(multi bool, services ...core.ConvertService) core.ConvertService {
return &combined{multi: multi, sources: services}
}
type combined struct {
sources []core.ConvertService
// this feature flag can be removed once we solve for
// https://github.com/harness/drone/pull/2994#issuecomment-795955312
multi bool
}
func (c *combined) Convert(ctx context.Context, req *core.ConvertArgs) (*core.Config, error) {
@ -42,7 +46,11 @@ func (c *combined) Convert(ctx context.Context, req *core.ConvertArgs) (*core.Co
if config.Data == "" {
continue
}
return config, nil
if c.multi {
req.Config = config
} else {
return config, nil
}
}
return req.Config, nil
}

View file

@ -39,7 +39,7 @@ func TestCombine(t *testing.T) {
service := mock.NewMockConvertService(controller)
service.EXPECT().Convert(noContext, args).Return(resp, nil)
result, err := Combine(service).Convert(noContext, args)
result, err := Combine(false, service).Convert(noContext, args)
if err != nil {
t.Error(err)
return
@ -58,7 +58,7 @@ func TestCombineErr(t *testing.T) {
service := mock.NewMockConvertService(controller)
service.EXPECT().Convert(noContext, nil).Return(nil, resp)
_, err := Combine(service).Convert(noContext, nil)
_, err := Combine(false, service).Convert(noContext, nil)
if err != resp {
t.Errorf("expected convert service error")
}
@ -85,7 +85,7 @@ func TestCombineNoConfig(t *testing.T) {
service3 := mock.NewMockConvertService(controller)
service3.EXPECT().Convert(noContext, args).Return(resp, nil)
result, err := Combine(service1, service2, service3).Convert(noContext, args)
result, err := Combine(false, service1, service2, service3).Convert(noContext, args)
if err != nil {
t.Error(err)
return
@ -110,7 +110,7 @@ func TestCombineEmptyConfig(t *testing.T) {
service1 := mock.NewMockConvertService(controller)
service1.EXPECT().Convert(noContext, args).Return(nil, nil)
result, err := Combine(service1).Convert(noContext, args)
result, err := Combine(false, service1).Convert(noContext, args)
if err != nil {
t.Error(err)
return

View file

@ -2,6 +2,8 @@ package jsonnet
import (
"io/ioutil"
"runtime"
"strings"
"testing"
"github.com/drone/drone/core"
@ -44,13 +46,19 @@ func TestParse(t *testing.T) {
req.Config.Data = string(before)
parsedFile, err := Parse(req, nil, 0, template, templateData)
got, err := Parse(req, nil, 0, template, templateData)
if err != nil {
t.Error(err)
return
}
if want, got := parsedFile, string(after); want != got {
want := string(after)
// on windows line endings are \r\n, lets change them to linux for comparison
if runtime.GOOS == "windows" {
want = strings.Replace(want, "\r\n", "\n", -1)
}
if want != got {
t.Errorf("Want %q got %q", want, got)
}
}
@ -82,13 +90,19 @@ func TestParseJsonnetNotTemplateFile(t *testing.T) {
req.Repo.Config = "plugin.jsonnet"
req.Config.Data = string(before)
parsedFile, err := Parse(req, nil, 0, nil, nil)
got, err := Parse(req, nil, 0, nil, nil)
if err != nil {
t.Error(err)
return
}
if want, got := parsedFile, string(after); want != got {
want := string(after)
// on windows line endings are \r\n, lets change them to linux for comparison
if runtime.GOOS == "windows" {
want = strings.Replace(want, "\r\n", "\n", -1)
}
if want != got {
t.Errorf("Want %q got %q", want, got)
}
}

View file

@ -2,6 +2,7 @@
// Use of this source code is governed by the Drone Non-Commercial License
// that can be found in the LICENSE file.
//go:build !oss
// +build !oss
package converter
@ -36,7 +37,7 @@ func Remote(endpoint, signer, extension string, skipVerify bool, timeout time.Du
type remote struct {
client converter.Plugin
extension string
timeout time.Duration
timeout time.Duration
}
func (g *remote) Convert(ctx context.Context, in *core.ConvertArgs) (*core.Config, error) {
@ -61,6 +62,10 @@ func (g *remote) Convert(ctx context.Context, in *core.ConvertArgs) (*core.Confi
Config: drone.Config{
Data: in.Config.Data,
},
Token: drone.Token{
Access: in.User.Token,
Refresh: in.User.Refresh,
},
}
res, err := g.client.Convert(ctx, req)

View file

@ -16,6 +16,8 @@ package converter
import (
"io/ioutil"
"runtime"
"strings"
"testing"
"github.com/drone/drone/core"
@ -117,7 +119,14 @@ func TestConvert_Multi(t *testing.T) {
return
}
if want, got := config.Data, string(after); want != got {
want := string(after)
// on windows line endings are \r\n, lets change them to linux for comparison
if runtime.GOOS == "windows" {
want = strings.Replace(want, "\r\n", "\n", -1)
}
got := config.Data
if want != got {
t.Errorf("Want %q got %q", want, got)
}
}

View file

@ -17,6 +17,8 @@ package converter
import (
"encoding/json"
"io/ioutil"
"runtime"
"strings"
"testing"
"github.com/drone/drone/core"
@ -234,7 +236,14 @@ func TestTemplatePluginConvertJsonnet(t *testing.T) {
return
}
if want, got := config.Data, string(after); want != got {
want := string(after)
// on windows line endings are \r\n, lets change them to linux for comparison
if runtime.GOOS == "windows" {
want = strings.Replace(want, "\r\n", "\n", -1)
}
got := config.Data
if want != got {
t.Errorf("Want %q got %q", want, got)
}
}
@ -388,6 +397,7 @@ func TestTemplatePluginConvertYaml(t *testing.T) {
t.Errorf("Want %q got %q", want, got)
}
}
// tests to check error is thrown if user has already loaded a template file of invalid extension
// and refers to it in the drone.yml file
func TestTemplatePluginConvertInvalidTemplateExtension(t *testing.T) {
@ -436,3 +446,65 @@ func TestTemplatePluginConvertInvalidTemplateExtension(t *testing.T) {
t.Errorf("template extension invalid. must be yaml, starlark or jsonnet")
}
}
func TestTemplatePluginConvertYamlWithComment(t *testing.T) {
templateArgs, err := ioutil.ReadFile("testdata/yaml.template.comment.yml")
if err != nil {
t.Error(err)
return
}
req := &core.ConvertArgs{
Build: &core.Build{
After: "3d21ec53a331a6f037a91c368710b99387d012c1",
},
Repo: &core.Repository{
Slug: "octocat/hello-world",
Config: ".drone.yml",
Namespace: "octocat",
},
Config: &core.Config{
Data: string(templateArgs),
},
}
beforeInput, err := ioutil.ReadFile("testdata/yaml.input.yml")
if err != nil {
t.Error(err)
return
}
after, err := ioutil.ReadFile("testdata/yaml.input.golden")
if err != nil {
t.Error(err)
return
}
template := &core.Template{
Name: "plugin.yaml",
Data: string(beforeInput),
Namespace: "octocat",
}
controller := gomock.NewController(t)
defer controller.Finish()
templates := mock.NewMockTemplateStore(controller)
templates.EXPECT().FindName(gomock.Any(), template.Name, req.Repo.Namespace).Return(template, nil)
plugin := Template(templates, 0)
config, err := plugin.Convert(noContext, req)
if err != nil {
t.Error(err)
return
}
if config == nil {
t.Error("Want non-nil configuration")
return
}
if want, got := config.Data, string(after); want != got {
t.Errorf("Want %q got %q", want, got)
}
}

View file

@ -0,0 +1,8 @@
---
# this is a comment
kind: template
load: plugin.yaml
data:
stepName: my_step
image: my_image
commands: my_command

View file

@ -57,7 +57,9 @@ func (s *service) List(ctx context.Context, user *core.User) ([]*core.Repository
return nil, err
}
for _, src := range result {
repos = append(repos, convertRepository(src, s.visibility, s.trusted))
if src != nil {
repos = append(repos, convertRepository(src, s.visibility, s.trusted))
}
}
opts.Page = meta.Page.Next
opts.URL = meta.Page.NextURL

View file

@ -246,3 +246,44 @@ func TestList_RefreshErr(t *testing.T) {
t.Errorf("Expect error refreshing token")
}
}
func TestListWithNilRepo(t *testing.T) {
controller := gomock.NewController(t)
defer controller.Finish()
mockUser := &core.User{}
mockRepos := []*scm.Repository{
{
Namespace: "octocat",
Name: "hello-world",
},
nil,
}
mockRepoService := mockscm.NewMockRepositoryService(controller)
mockRepoService.EXPECT().List(gomock.Any(), gomock.Any()).Return(mockRepos, &scm.Response{}, nil)
mockRenewer := mock.NewMockRenewer(controller)
mockRenewer.EXPECT().Renew(gomock.Any(), mockUser, false)
client := new(scm.Client)
client.Repositories = mockRepoService
want := []*core.Repository{
{
Namespace: "octocat",
Name: "hello-world",
Slug: "octocat/hello-world",
Visibility: "public",
},
}
service := New(client, mockRenewer, "", false)
got, err := service.List(noContext, mockUser)
if err != nil {
t.Error(err)
}
if diff := cmp.Diff(got, want); diff != "" {
t.Errorf(diff)
}
}

View file

@ -35,6 +35,7 @@ func convertRepository(src *scm.Repository, visibility string, trusted bool) *co
Visibility: convertVisibility(src, visibility),
Branch: src.Branch,
Trusted: trusted,
Archived: src.Archived,
}
}

View file

@ -76,7 +76,7 @@ func (s *service) Send(ctx context.Context, user *core.User, req *core.StatusInp
Desc: createDesc(req.Build.Status),
State: convertStatus(req.Build.Status),
Target: fmt.Sprintf("%s/%s/%d", s.base, req.Repo.Slug, req.Build.Number),
Environment: req.Build.Target,
Environment: req.Build.Deploy,
})
return err
}

View file

@ -105,7 +105,6 @@ func TestCreateDesc(t *testing.T) {
}
func TestConvertStatus(t *testing.T) {
tests := []struct {
from string
to scm.State

View file

@ -16,6 +16,7 @@ package syncer
import (
"context"
"runtime/debug"
"strings"
"time"
@ -66,7 +67,7 @@ func (s *Synchronizer) Sync(ctx context.Context, user *core.User) (*core.Batch,
// a panic that should absolutely never happen.
if err := recover(); err != nil {
logger = logger.WithField("error", err)
logger.Errorln("syncer: unexpected panic")
logger.Errorf("syncer: unexpected panic\n%s\n", debug.Stack())
}
// when the synchronization process is complete
@ -110,6 +111,13 @@ func (s *Synchronizer) Sync(ctx context.Context, user *core.User) (*core.Batch,
WithField("uid", repo.UID).
Traceln("syncer: skipping subrepositories")
}
} else if repo.Archived {
if logrus.GetLevel() == logrus.TraceLevel {
logger.WithField("namespace", repo.Namespace).
WithField("name", repo.Name).
WithField("uid", repo.UID).
Traceln("syncer: skipping archived repositories")
}
} else if s.match(repo) {
remote[repo.UID] = repo
if logrus.GetLevel() == logrus.TraceLevel {

View file

@ -434,3 +434,52 @@ func TestSync_SkipSubrepo(t *testing.T) {
t.Errorf(diff)
}
}
func TestSyncArchive(t *testing.T) {
controller := gomock.NewController(t)
defer controller.Finish()
user := &core.User{ID: 1}
userStore := mock.NewMockUserStore(controller)
userStore.EXPECT().Update(gomock.Any(), user).Return(nil)
userStore.EXPECT().Update(gomock.Any(), user).Return(nil)
batcher := mock.NewMockBatcher(controller)
batcher.EXPECT().Batch(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil)
repoStore := mock.NewMockRepositoryStore(controller)
repoStore.EXPECT().List(gomock.Any(), gomock.Any()).Return([]*core.Repository{}, nil)
repoService := mock.NewMockRepositoryService(controller)
repoService.EXPECT().List(gomock.Any(), user).Return([]*core.Repository{
{
UID: "1",
Slug: "octocat/hello-world",
Namespace: "octocat",
Name: "hello-world",
Private: false,
Visibility: core.VisibilityPublic,
Archived: true,
},
}, nil)
s := New(
repoService,
repoStore,
userStore,
batcher,
)
got, err := s.Sync(context.Background(), user)
if err != nil {
t.Error(err)
}
want := &core.Batch{}
ignore := cmpopts.IgnoreFields(core.Repository{},
"Synced", "Created", "Updated")
if diff := cmp.Diff(got, want, ignore); len(diff) != 0 {
t.Errorf(diff)
}
}

View file

@ -48,6 +48,7 @@ func Connect() (*db.DB, error) {
func Reset(d *db.DB) {
d.Lock(func(tx db.Execer, _ db.Binder) error {
tx.Exec("DELETE FROM cron")
tx.Exec("DELETE FROM cards")
tx.Exec("DELETE FROM logs")
tx.Exec("DELETE FROM steps")
tx.Exec("DELETE FROM stages")
@ -56,6 +57,7 @@ func Reset(d *db.DB) {
tx.Exec("DELETE FROM perms")
tx.Exec("DELETE FROM repos")
tx.Exec("DELETE FROM users")
tx.Exec("DELETE FROM templates")
tx.Exec("DELETE FROM orgsecrets")
return nil
})

View file

@ -160,6 +160,10 @@ var migrations = []struct {
name: "create-table-template",
stmt: createTableTemplate,
},
{
name: "create-index-template-namespace",
stmt: createIndexTemplateNamespace,
},
{
name: "alter-table-steps-add-column-step-depends-on",
stmt: alterTableStepsAddColumnStepDependsOn,
@ -692,14 +696,16 @@ CREATE INDEX IF NOT EXISTS ix_latest_repo ON latest (latest_repo_id);
var createTableTemplate = `
CREATE TABLE IF NOT EXISTS templates (
template_id SERIAL PRIMARY KEY
,template_name TEXT UNIQUE
,template_name TEXT
,template_namespace VARCHAR(50)
,template_data BYTEA
,template_created INTEGER
,template_updated INTEGER
,UNIQUE(template_name, template_namespace)
);
`
var createIndexTemplateNamespace = `
CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace);
`

View file

@ -2,7 +2,7 @@
CREATE TABLE IF NOT EXISTS templates (
template_id SERIAL PRIMARY KEY
,template_name TEXT UNIQUE
,template_name TEXT
,template_namespace VARCHAR(50)
,template_data BYTEA
,template_created INTEGER
@ -10,4 +10,6 @@ CREATE TABLE IF NOT EXISTS templates (
,UNIQUE(template_name, template_namespace)
);
-- name: create-index-template-namespace
CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace);

View file

@ -160,6 +160,10 @@ var migrations = []struct {
name: "create-table-templates",
stmt: createTableTemplates,
},
{
name: "create-index-template-namespace",
stmt: createIndexTemplateNamespace,
},
{
name: "alter-table-steps-add-column-step-depends-on",
stmt: alterTableStepsAddColumnStepDependsOn,
@ -694,14 +698,16 @@ CREATE INDEX IF NOT EXISTS ix_latest_repo ON latest (latest_repo_id);
var createTableTemplates = `
CREATE TABLE IF NOT EXISTS templates (
template_id INTEGER PRIMARY KEY AUTOINCREMENT
,template_name TEXT UNIQUE
,template_name TEXT
,template_namespace TEXT COLLATE NOCASE
,template_data BLOB
,template_created INTEGER
,template_updated INTEGER
,UNIQUE(template_name, template_namespace)
,UNIQUE(template_name COLLATE NOCASE, template_namespace COLLATE NOCASE)
);
`
var createIndexTemplateNamespace = `
CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace);
`

View file

@ -2,12 +2,14 @@
CREATE TABLE IF NOT EXISTS templates (
template_id INTEGER PRIMARY KEY AUTOINCREMENT
,template_name TEXT UNIQUE
,template_name TEXT
,template_namespace TEXT COLLATE NOCASE
,template_data BLOB
,template_created INTEGER
,template_updated INTEGER
,UNIQUE(template_name, template_namespace)
,UNIQUE(template_name COLLATE NOCASE, template_namespace COLLATE NOCASE)
);
-- name: create-index-template-namespace
CREATE INDEX IF NOT EXISTS ix_template_namespace ON templates (template_namespace);

View file

@ -2,6 +2,7 @@
// Use of this source code is governed by the Drone Non-Commercial License
// that can be found in the LICENSE file.
//go:build !oss
// +build !oss
package template
@ -29,7 +30,7 @@ func TestTemplate(t *testing.T) {
}()
store := New(conn).(*templateStore)
t.Run("Create", testTemplateCreate(store))
t.Run("TestTemplates", testTemplateCreate(store))
}
func testTemplateCreate(store *templateStore) func(t *testing.T) {
@ -50,6 +51,8 @@ func testTemplateCreate(store *templateStore) func(t *testing.T) {
t.Errorf("Want template Id assigned, got %d", item.Id)
}
t.Run("CreateSameNameDiffOrg", testCreateWithSameNameDiffOrg(store))
t.Run("CreateSameNameSameOrgShouldError", testCreateSameNameSameOrgShouldError(store))
t.Run("Find", testTemplateFind(store, item))
t.Run("FindName", testTemplateFindName(store))
t.Run("ListAll", testTemplateListAll(store))
@ -59,6 +62,43 @@ func testTemplateCreate(store *templateStore) func(t *testing.T) {
}
}
func testCreateWithSameNameDiffOrg(store *templateStore) func(t *testing.T) {
return func(t *testing.T) {
item := &core.Template{
Id: 1,
Name: "my_template",
Namespace: "my_org2",
Data: "some_template_data",
Created: 1,
Updated: 2,
}
err := store.Create(noContext, item)
if err != nil {
t.Error(err)
}
if item.Id == 0 {
t.Errorf("Want template Id assigned, got %d", item.Id)
}
}
}
func testCreateSameNameSameOrgShouldError(store *templateStore) func(t *testing.T) {
return func(t *testing.T) {
item := &core.Template{
Id: 3,
Name: "my_template",
Namespace: "my_org2",
Data: "some_template_data",
Created: 1,
Updated: 2,
}
err := store.Create(noContext, item)
if err == nil {
t.Error(err)
}
}
}
func testTemplateFind(store *templateStore, template *core.Template) func(t *testing.T) {
return func(t *testing.T) {
item, err := store.Find(noContext, template.Id)
@ -95,6 +135,20 @@ func testTemplate(item *core.Template) func(t *testing.T) {
}
}
func testTemplate2(item *core.Template) func(t *testing.T) {
return func(t *testing.T) {
if got, want := item.Name, "my_template"; got != want {
t.Errorf("Want template name %q, got %q", want, got)
}
if got, want := item.Data, "some_template_data"; got != want {
t.Errorf("Want template data %q, got %q", want, got)
}
if got, want := item.Namespace, "my_org2"; got != want {
t.Errorf("Want template org %q, got %q", want, got)
}
}
}
func testTemplateListAll(store *templateStore) func(t *testing.T) {
return func(t *testing.T) {
list, err := store.ListAll(noContext)
@ -102,10 +156,11 @@ func testTemplateListAll(store *templateStore) func(t *testing.T) {
t.Error(err)
return
}
if got, want := len(list), 1; got != want {
if got, want := len(list), 2; got != want {
t.Errorf("Want count %d, got %d", want, got)
} else {
t.Run("Fields", testTemplate(list[0]))
t.Run("Fields", testTemplate2(list[1]))
}
}
}

View file

@ -25,9 +25,9 @@ var (
// VersionMajor is for an API incompatible changes.
VersionMajor int64 = 2
// VersionMinor is for functionality in a backwards-compatible manner.
VersionMinor int64 = 6
VersionMinor int64 = 12
// VersionPatch is for backwards-compatible bug fixes.
VersionPatch int64 = 0
VersionPatch int64 = 1
// VersionPre indicates prerelease.
VersionPre = ""
// VersionDev indicates development branch. Releases will be empty string.

View file

@ -2,6 +2,7 @@
// Use of this source code is governed by the Drone Non-Commercial License
// that can be found in the LICENSE file.
//go:build !oss
// +build !oss
package version
@ -9,7 +10,7 @@ package version
import "testing"
func TestVersion(t *testing.T) {
if got, want := Version.String(), "2.6.0"; got != want {
if got, want := Version.String(), "2.12.1"; got != want {
t.Errorf("Want version %s, got %s", want, got)
}
}