-
Notifications
You must be signed in to change notification settings - Fork 460
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
add github actions workflow for build and test on linux #973
Conversation
- use matrix to parametrize swift and protobuf versions - cache conformance test runner
ed2525a
to
baac1e3
Compare
Couple of notes/ideas: We will need to be vigilant about updating the protobuf versions here -- in particular, the protocolbuffers project does regularly expand the conformance test and we do want to track that. It might be worth asking the protocolbuffers project if they could include the conformance test binary in their release package (or a separate package?) to avoid the overhead of building it every time. |
I sent some email to them directly to ask about it. But opening an issue in parallel on their project wouldn't hurt. |
In theory the caching step should help with this, though I've yet to see it working. For example, I see messages in the logs that suggest it is caching something:
But in my limited testing the very next build still shows a cache miss:
My suspicion is that it isn't working because I don't have this merged to master yet. The docs say there are some restrictions: https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache |
I might be able to partially automate this. Actions can be scheduled like a cronjob so one could potentially check for new protocol buffer releases and open a PR to add it to the test matrix automatically. |
Actually, thinking some more about this, I think we might have a catch-22 here around the version of protocolbuffers/protobuf to use here. All we need directly from that checkout is a built copy of Should we just set up CI to always use master on protocolbuffer/protobuf? About the only other option I can see would be to try to teach the |
I think you could use branching to solve this. For example, master branch of swift-protobuf can be configured to pull and build from master branch of protocolbuffer. When you go to release a version of swift-protobuf you can make a branch and modify the CI to use latest version tag of protocolbuffer. The problem I see with this approach is that breakage in protocolbuffer master becomes breakage in swift-protobuf master. Another approach would be to have a dev or unstable branch of swift-protobuf that is pointed at protocolbuffer master. It could be used as a staging area for “breaking” changes such as adopting new unreleased protocolbuffer api or a new version of Swift and to ensure changes in protocolbuffer master are not breaking swift-protobuf. This would allow master swift-protobuf to remain stable and pinned against a released version. Presumably you’d not merge changes to master until protocolbuffer has actually released a version with those changes. |
In the case of conformance fixes, we've land them immediately because it means the library is doing something wrong. And we usually do our own release shortly after to get all consumers on the correct behaviors. There's not to get SwiftProtobuf on the correct behavior asap and ensure it stays on the correct behavior. New features in the proto grammar is more of a grey area. There really haven't been any that impacted SwiftProtobuf since we hit the 1.0 milestone, but that's not always going to remain true. If/when something new is added we'll need to be able to work on updating to support it. I'm not sure I follow the comment about master remaining "stable", "stable" would be releases and master should be evolving to be ready for the next release, no? If master were to stay pinned to an old version of protobuf it means we always have to scrabble when something outside our control does a release. If we force that work to happen on a branch, then it means we're potentially updating one (or more branches) with any other bug fixes/new features that also happen during that time span and/or still having a scramble to merge/resolve a branch against master on short order after they release. Another option might not be to completely float on master, but to target a specific hash on master, that way if/when things like new conformance tests and/or new proto features are in flight, master's CI can be moved along with the matching changes here. |
SwiftProtobuf's master branch is our dev branch. We do all development in master and branch for releases. (I know some people do it the other way around.)
Practically speaking, that hasn't been a problem. The PB folks do a pretty good job of keeping their master branch in usable shape.
But these happen so rarely that I think we'll do fine dealing with them as/when they occur. I don't see any need to modify anything here to specifically deal with such eventuality. |
Just checked the conformance test, the master version has more tests at the moment. So by pinning to release we already start running a subset of what we likely should be always tracking.
I guess my concern is are we saying the moment it happens we move to master? If so, why not just start there? Anyway, I'll defer to @tbkka for where to start things out, but given some of the open upstream issues, I'm pretty sure we're we see changes soon. |
Back to the main point of this CL -
|
.github/workflows/linux_build.yml
Outdated
runs-on: ubuntu-18.04 | ||
strategy: | ||
matrix: | ||
swift: ["5.2", "5.1.5"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does "5.2" float? i.e. - is it 5.2 or does it auto pick up 5.2.1 since they just released that for linux? (and if/when there is a 5.2.2 would it get that)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not float, it will need to be updated. 5.2.1 had been released, but there were no docker images yet when I made this PR. As I said above, I think we can have a scheduled action for scraping for updates.
I can add swift 4.2 to the matrix. Before I do this work, I wanted to resolve the issue of what version of protoc we want to target. If master, I need to make changes to the steps to build it. |
Sure, the line |
- allow using any gitref from protobuf repo - cache entire protobuf directory
OK, updates pushed. Highlights:
As before, see toffaletti#1 for the actual runs of the workflow in the commits. |
@tbkka @thomasvl friendly ping on this. Another minor update, I got a workaround for building a more accurate cache key for protobuf: actions/checkout#209 |
So we just update that one hash when we want to test a newer version of master? Works for me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I follow most of the yml, but seems to make sense. 😄
ps - I really hope we can add macOS in a follow up. |
Merged. Let's see how it works. We can continue revising as needed. |
Does something need to be enabled on the project? Or where does one look to see the post submit build/results for master? Edit: /~https://github.com/apple/swift-protobuf/actions doesn't seem to list anything (and Actions isn't listed as a "tab" for this repo in general. |
@tbkka Looks like you will need to enable the actions then. |
I'll look into it. There may be some administrative hurdles to jump through, though. |
matrix: | ||
swift: ["5.2.1-bionic", "5.1.5-bionic", "4.2.4"] | ||
# master as of 4/4/2020: cf601047ebf87cf7f443753ded41132eb689cb10 | ||
protobuf_gitref: ["v3.11.4", "cf601047ebf87cf7f443753ded41132eb689cb10"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we just update that one hash when we want to test a newer version of master? Works for me.
Yes, though this was a temporary workaround until I got an answer here: actions/checkout#209
With that I will be able to put "master"
in this list and make the caching safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth landing that fix now while @tbkka works on getting the hook set up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, I'll work on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue 993 is a newer failure on updated conformance tests, so it would be nice to get our master validation update to float with those commits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@toffaletti how do we check if the caching of things is working? Looking at /~https://github.com/apple/swift-protobuf/pull/994/checks it seems like it is building protobuf, I would have thought it would be cached from when @tbkka set things up and did a test PR to ensure they built?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ll take a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it seems like the cache should have had a cache hit, in
/~https://github.com/apple/swift-protobuf/runs/664761605?check_suite_focus=true I see
Cache not found for input keys: Linux-ubuntu-18.04-protobuf-cf601047ebf87cf7f443753ded41132eb689cb10.
then later in Post Cache:
Cache saved successfully
And in the other parallel builds:
Running JavaScript Action with default external tool: node12
[warning]Cache already exists. Scope: refs/pull/991/merge, Key: Linux-ubuntu-18.04-protobuf-cf601047ebf87cf7f443753ded41132eb689cb10, Version: (null)
But then 3 days later in your PR a cache miss for the same key:
/~https://github.com/apple/swift-protobuf/runs/674773193?check_suite_focus=true
Cache not found for input keys: Linux-ubuntu-18.04-protobuf-cf601047ebf87cf7f443753ded41132eb689cb10.
However, I do see at least one cache hit:
/~https://github.com/apple/swift-protobuf/runs/675011233?check_suite_focus=true
Cache Size: ~182 MB (190677067 B)
/bin/tar -xz -f /__w/_temp/90437206-2a9e-46a5-9320-7515799d57c5/cache.tgz -C /__w/swift-protobuf/swift-protobuf/protobuf
Cache restored from key: Linux-ubuntu-18.04-protobuf-6935eae45c99926a000ecbef0be20dfd3d159e71
It seems like the cache isn't reliable. I will open an issue on /~https://github.com/actions/cache and update here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actions/cache#310 - will see if they can investigate this better than I'm able to. Meanwhile I'll work on the improved caching for floating on master.
Use the official swift docker images to execute
make build test
on pull requests targeting master. Creates a test matrix for swift and protobuf versions, currently running tests on both swift 5.1.5 and 5.2 with protobuf 3.11.4. The sub-targets of the test target are broken into steps to allow easier diagnostics and caching of the conformance test runner.I tried to get caching of the conformance-test-runner working, but I haven't seen it work yet and I'm not sure why.
To see this working: /~https://github.com/toffaletti/swift-protobuf/pull/1/checks