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

Woodpecker CI cache fixes #1309

Merged
merged 7 commits into from
Jan 4, 2024
Merged

Woodpecker CI cache fixes #1309

merged 7 commits into from
Jan 4, 2024

Conversation

Nutomic
Copy link
Member

@Nutomic Nutomic commented Dec 22, 2023

Same as LemmyNet/lemmy#4276:

  • Fail CI run on cache error so that we can actually notice and fix problems
  • Increase timeout for cache operations (default is only 3m)
  • Disable cache compression (takes unnecessary time)

Also change cache rebuild to run only on main branch, to prevent random attackers from writing into the cache from a PR.

@Nutomic Nutomic marked this pull request as draft December 22, 2023 10:00
@Nutomic Nutomic marked this pull request as ready for review December 22, 2023 11:17
.woodpecker.yml Outdated
mount:
- ".gradle"
secrets:
[MINIO_ENDPOINT, MINIO_WRITE_USER, MINIO_WRITE_PASSWORD, MINIO_BUCKET]
when:
- path:
include: ["app/build.gradle.kts"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could this be kept? I had added this, because I only want to save the new caches if something had changed.

Copy link
Member Author

Choose a reason for hiding this comment

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

The problem is that anyone can change the file in a PR, and then potentially get access to secrets to mess with the cache. Maybe a better option would be a cronjob which automatically rebuilds the cache every night or so.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah yeah the events are OR not AND ;/

I guess it will have to be like this

Copy link
Collaborator

@MV-GH MV-GH Dec 22, 2023

Choose a reason for hiding this comment

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

Actually this wouldn't prevent that at all. Anyone can edit this workflow, set whatever event they want and trigger a pr that updates the caches / Access the secrets

Copy link
Collaborator

Choose a reason for hiding this comment

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

In Github you can probably do a "hack" where you can set a secret only available (in Environment) if the file hasn't changed and another environment that allows only access to the same secret if approved by a required reviewer.

In Woodpecker it doesn't seem possible to do something similar. https://woodpecker-ci.org/docs/usage/secrets#use-in-pull-requests-events

Copy link
Member Author

Choose a reason for hiding this comment

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

Thats true. Ive changed it back now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is deemed too much of a security hazard, the caching can be removed, we don't gain that much from it. The biggest improvement was already made by setting the .gradle as ENV. This allowed it to reuse the gradle cache between steps

Copy link
Member Author

@Nutomic Nutomic Dec 26, 2023

Choose a reason for hiding this comment

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

Its mostly a theoretical problem, at least so far it hasnt been abused in practice. And we would probably notice if someone opened a malicious PR.

Any idea why the build is failing?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems it failed to download a depency, network issues prob, try again by pushing a commit

@dessalines dessalines merged commit e1922ea into LemmyNet:main Jan 4, 2024
1 check passed
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