Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use CI_JOB_TOKEN if no PAT provided #7

Closed

Conversation

superewald
Copy link
Contributor

@superewald superewald commented Oct 4, 2023

This PR adds a feature to use the CI_JOB_TOKEN provided for Gitlab CI jobs by default if no PAT was configured (as requested in go-semantic-release/semantic-release#141).

implementation

  • If no PAT is provided with the config or env vars the plugin defaults to use the CI_JOB_TOKEN and the gitlab.JobClient instead
  • GetCommit and GetReleases will fall back to the Git Provider implementations because the job token can't access private repository informations through the API.

tests

I ran tests on a public and private repository in gitlab, both of them succeeded. Probably adding unit tests would be good but I can't think of a good way of testing the feature outside the gitlab ci.

pkg/provider/gitlab.go Show resolved Hide resolved
pkg/provider/gitlab.go Show resolved Hide resolved
@superewald superewald marked this pull request as ready for review October 4, 2023 13:18
@superewald
Copy link
Contributor Author

@christophwitzko are unit tests for this feature demanded ? If so I would need a simple guideline what exactly to test

pkg/provider/gitlab.go Outdated Show resolved Hide resolved
pkg/provider/gitlab.go Show resolved Hide resolved
@cliedeman
Copy link
Contributor

Thanks @superewald looks good to me.

I would also like @christophwitzko to weigh in as he wrote the git provider.

On tests: I agree that unit tests are probably uncessary.

Copy link
Member

@christophwitzko christophwitzko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @superewald for implementing this. I left some smaller comments. ☺️

@superewald
Copy link
Contributor Author

I'm happy to contribute to this awesome project :)
I have some unrelated questions on the other repos but actually don't want to spam the issues, do we have a place to discuss the project or should I go with issues ?

@christophwitzko
Copy link
Member

Glad to hear! ☺️😎
Yes, I think creating issues is currently the best way to do so.

@christophwitzko
Copy link
Member

It seems that the Windows build is failing because of some gcc errors. Will hopefully have time to take a look later today. (probably we have to add CGO_ENABLED=0 😅)

@superewald
Copy link
Contributor Author

It seems that the Windows build is failing because of some gcc errors. Will hopefully have time to take a look later today. (probably we have to add CGO_ENABLED=0 😅)

It's a known bug with GO < 1.20 and windows 2022 image (golang/go#51007). There are 3 possible fixes:

  1. disable CGO (not sure if thats okey due to dependencies)
  2. use GO > 1.20
  3. use windows 2019 image if go < 1.20

@christophwitzko
Copy link
Member

I updated go and rebased your pr onto master. 🙏
https://github.com/go-semantic-release/provider-gitlab/releases/tag/v1.13.0

Thanks again for your contribution 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants