-
Notifications
You must be signed in to change notification settings - Fork 791
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
Migrate CircleCI workflows to GitHub Actions (1/3) #3302
Conversation
e5752ef
to
0542f3f
Compare
- name: Sym Link Expected Path to Workspace | ||
run: | | ||
mkdir -p /go/src/github.com/cortexproject/cortex | ||
ln -s $GITHUB_WORKSPACE/* /go/src/github.com/cortexproject/cortex |
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.
A significant number of commands in the Makefile were hardcoded with an assumed file structure of the CI container. make sure previous commands don’t break a symlink was created instead from the hardcoded “expected” working directory go/src/github.com/cortexproject/cortex
to the actual working directory $GITHUB_WORKSPACE
.
- name: Zip Images | ||
run: tar -zcvf images.tar.gz /tmp/images | ||
- name: Upload Images Artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: Docker Images | ||
path: ./images.tar.gz |
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.
As of Oct 2020 GitHub Actions does not persist between different jobs in the same workflow. Each job is run on a fresh virtual environment. As such, we need to upload and download artifacts to share data between jobs.
Docker Images are zipped before uploading as a workaround. The images contain characters that are illegal in the upload-artifact action.
d383cf7
to
19f90c4
Compare
bb100e5
to
df057f0
Compare
Signed-off-by: Azfaar Qureshi <azfaarq@amazon.com>
Signed-off-by: Azfaar Qureshi <azfaarq@amazon.com>
Signed-off-by: Azfaar Qureshi <azfaarq@amazon.com>
df057f0
to
f96681c
Compare
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.
Very good job! Overall LGTM. I just left few questions here and there, but I can't see any blocker.
lint: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: quay.io/cortexproject/build-image:update-golang-1.14.9-eb0c8d4d2 |
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.
Do you think we can use something similar to defaults: &defaults
in the CircleCI yaml, in order to avoid the repetition of image: quay.io/cortexproject/build-image:update-golang-1.14.9-eb0c8d4d2
and being able to define the build image only once in this file?
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.
There exists a "defaults" field for GitHub actions, but it automatically applies to all jobs in the workflow. The integration and integration-configs-db jobs that will be added to the workflow with PR 2/3 of the migration do not use the default container so using a default would require explicitly removing the default container from those jobs by setting them to None.
We would like to reuse setup commands and default containers with something like commands in CircleCI, but this feature is not available yet on GitHub Actions.
Status: https://github.community/t/reusing-sharing-inheriting-steps-between-jobs-declarations/16851
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.
GHA doesn't support yaml anchors yet because of some security reasons but they are actively working 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.
Would it be possible to use env variable instead?
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.
This is not a blocker for getting this PR merged. We can discuss it separately.
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: website public | ||
path: website/public/ | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: Frontend Protobuf | ||
path: pkg/querier/frontend/frontend.pb.go | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: Caching Index Client Protobuf | ||
path: pkg/chunk/storage/caching_index_client.pb.go | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: Ring Protobuf | ||
path: pkg/ring/ring.pb.go | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: Cortex Protobuf | ||
path: pkg/ingester/client/cortex.pb.go | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: Rules Protobuf | ||
path: pkg/ruler/rules/rules.pb.go |
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.
Have you figured out if we actually need to upload these artifacts? I know we do it in CircleCI but I have the feeling they're unused (at least I don't remember if we still use them anywhere).
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.
Oh, we included it because this PR here made it seem like there was an explicit decision to save these files. Has the situation changed? But you are right, those artifacts are not used anywhere else within CI
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.
Since then we have added these files into Git, so I think #1224 is not relevant anymore.
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.
(In #1399)
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 also think we don't need to store these artifacts anymore.
Signed-off-by: Azfaar Qureshi <azfaarq@amazon.com>
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.
Great job, thank you very much for doing this!
(Nit: In next PRs I would suggest moving the comments from README.md into YAML files, to keep it at one place.)
- name: Sym link expected path to github workspace | ||
run: | | ||
mkdir -p /go/src/github.com/cortexproject/cortex | ||
ln -s $GITHUB_WORKSPACE/* /go/src/github.com/cortexproject/cortex |
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.
This looks suspicious... why create many links instead of one:
mkdir -p /go/src/github.com/cortexproject/
ln -s "$GITHUB_WORKSPACE" /go/src/github.com/cortexproject/cortex
*Note:* Docker Images are zipped before uploading as a workaround. The images contain characters that are illegal in the upload-artifact action. | ||
```yaml | ||
- name: Compressing Images | ||
run: tar -zcvf images.tar.gz /tmp/images |
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 sure if compression gives us anything here. We can use tar
without -z
flag to make it run faster (but use more disk space).
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.
The compression was in fact unnecessary. We removed it in the subsequent migration PR: #3341
steps: | ||
- name: Checkout Repo | ||
uses: actions/checkout@v1 | ||
- name: Sym Link Expected Path to Workspace |
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.
This linking is explained in README, apart from doing review, who reads that? I'd include the explanations from README directly into this file.
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.
Added a comment explaining this within the code itself in the subsequent PR to address this.
#3341
lint: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: quay.io/cortexproject/build-image:update-golang-1.14.9-eb0c8d4d2 |
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.
Would it be possible to use env variable instead?
mkdir -p /go/src/github.com/cortexproject/cortex | ||
ln -s $GITHUB_WORKSPACE/* /go/src/github.com/cortexproject/cortex | ||
- name: Lint | ||
run: make BUILD_IN_CONTAINER=false lint |
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.
Should we set BUILD_IN_CONTAINER=false
as env variable for entire workflow or at least individual jobs?
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.
But BUILD_IN_CONTAINER
is not an environment variable. At least, doesn't work if you set it as env variable. Am I missing anything?
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: website public | ||
path: website/public/ | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: Frontend Protobuf | ||
path: pkg/querier/frontend/frontend.pb.go | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: Caching Index Client Protobuf | ||
path: pkg/chunk/storage/caching_index_client.pb.go | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: Ring Protobuf | ||
path: pkg/ring/ring.pb.go | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: Cortex Protobuf | ||
path: pkg/ingester/client/cortex.pb.go | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: Rules Protobuf | ||
path: pkg/ruler/rules/rules.pb.go |
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.
Since then we have added these files into Git, so I think #1224 is not relevant anymore.
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.
LGTM, thanks!
mkdir -p /go/src/github.com/cortexproject/cortex | ||
ln -s $GITHUB_WORKSPACE/* /go/src/github.com/cortexproject/cortex | ||
- name: Lint | ||
run: make BUILD_IN_CONTAINER=false lint |
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.
But BUILD_IN_CONTAINER
is not an environment variable. At least, doesn't work if you set it as env variable. Am I missing anything?
@AzfaarQureshi We merged the PR since it's in a good shape, but we would be glad if you could address the remaining comments in a subsequent PR. Thanks! |
"Every environment variable that make sees when it starts up is transformed into a make variable with the same name and value." (from GNU Make docs) But you say that it doesn't work when set as env variable, so perhaps there is something in our |
What this PR does
This is PR 1/3 of migrating Cortex's CI from CircleCI to GitHub Actions:
Part 1/3 👈
test-build-deploy
workflow under.github/workflows
lint
test
build
master
or when any PR is opened. However CD jobs will only run on the master branch and will be skipped otherwisePart 2/3
build
integration
integration-config-db
Part 3/3
deploy_website
is dependant onbuild, test
deploy
is dependant onbuild, test, lint, integration, integration-config-db
Which issue(s) this PR fixes:
Fixes #3274
Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]