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

Dockerised binding regeneration #257

Merged
merged 25 commits into from
Jun 27, 2024
Merged

Dockerised binding regeneration #257

merged 25 commits into from
Jun 27, 2024

Conversation

keynmol
Copy link
Contributor

@keynmol keynmol commented Jun 25, 2024

Fixes GRAPH-709

Several of us had problems with local environment trying to regenerate bindings.
We're switching to the dockerised build as a stopgap solution.

Test plan

  • new script will be used on CI

@keynmol keynmol force-pushed the docker-for-bindings-generator branch from 217fd22 to 2ffd6a8 Compare June 25, 2024 12:37
@keynmol keynmol marked this pull request as ready for review June 25, 2024 13:16
@keynmol keynmol changed the title WIP docker container for bindings generation Dockerised binding regeneration Jun 25, 2024
Development.md Outdated Show resolved Hide resolved
.dockerignore Outdated Show resolved Hide resolved
@keynmol
Copy link
Contributor Author

keynmol commented Jun 25, 2024

all done

keynmol added 2 commits June 26, 2024 14:15
This is the minimal version I could find that fits all criteria:

1. Determinstic output: tree-sitter/tree-sitter#2755
2. Published for ARM64
3. Tests for reprolang pass
@@ -1,5 +1,6 @@
golang 1.19.10
nodejs 16.7.0
nodejs 16.20.2
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nodejs version in 16.x lineage that supports arm64 (for local development)

@@ -12,6 +12,6 @@
"nan": "^2.15.0"
},
"devDependencies": {
"tree-sitter-cli": "^0.20.4"
"tree-sitter-cli": "0.21.0"
Copy link
Contributor Author

@keynmol keynmol Jun 26, 2024

Choose a reason for hiding this comment

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

Minimal version that is deterministic (tree-sitter/tree-sitter#2755), and available from arm64 (for local work), and available on NPM: https://www.npmjs.com/package/tree-sitter-cli?activeTab=versions (0.20.9 is missing)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's for tests only, so doesn't matter

@@ -19,7 +19,7 @@ fi

echo "--- Haskell ---"
command -v cabal > /dev/null 2>&1 || { echo >&2 "Haskell's 'cabal' command is not installed. Please install it first via https://www.haskell.org/ghcup/"; exit 1; }
cabal install proto-lens-protoc-0.7.1.1 ghc-source-gen-0.4.3.0 --overwrite-policy=always --ghc-options='-j2 +RTS -A32m' --installdir="$PWD/.bin"
cabal install proto-lens-protoc-0.8.0.1 ghc-source-gen-0.4.5.0 --overwrite-policy=always --ghc-options='-j2 +RTS -A32m' --installdir="$PWD/.bin"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bumps required because latest GHC doesn't support original versions...

Comment on lines +9 to +11
"build": "tsc --build --force bindings/typescript",
"prettier": "prettier --write --list-different '**/*.{ts,js(on)?,md,yml}'",
"prettier-check": "prettier --check '**/*.{ts,js(on)?,md,yml}'"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need to reference node_modules directly

push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
Copy link
Contributor Author

Choose a reason for hiding this comment

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

While this is slow (VERY slow), this workflow runs only on main and nothing depends on it - so it finishes when it finishes.

Copy link
Contributor

@kritzcreek kritzcreek left a comment

Choose a reason for hiding this comment

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

Using the container I can build all the bindings locally so I'm happy with this. Had one question about the image name

username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- run: docker pull ghcr.io/sourcegraph/scip:latest || echo "no suitable cache"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it scip-bindings-env everywhere else, but just scip here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, last place where I forgot to update it.
Frankly I don't think this helps at all, but I will still update the image once I'm back at the computer

@keynmol keynmol merged commit 76a272e into main Jun 27, 2024
6 checks passed
@keynmol keynmol deleted the docker-for-bindings-generator branch June 27, 2024 05:28
Comment on lines +6 to +9
# Configures this workflow to run every time a change is pushed to the branch called `release`.
on:
push:
branches: ['main']
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we limit running this only to specific commits? I'm worried we might get rate-limited if we try making a few changes in a single day given the size of the image. However, the docs don't mention any limits for total pull/push. https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry

🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think with Github's own registry rate limiting is not really an issue, but I will at least limit the concurrency of this job to avoid producing intermediate docker images for commits that aren't top of branch.

Comment on lines +33 to +35
# We're changing the owner of the checkout folder to a particular user id,
# matching the user id of `asdf` user we create inside the docker container.
sudo chown -R 1001:1001 . && ./dev/generate-all-in-docker.sh
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed because otherwise we might get permission errors inside the container? I don't understand why we need to create a separate asdf user inside the container.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason for this is that I failed to make asdf work with a root user - there were some errors coming out from asdf itself which I didn't have time to debug.

It's an eyesore to have to do this, but to avoid it we'd need to make asdf work with root – which might not be worth the time, given the entire docker container is just a minimal hack to get back to reproducibility.

@kritzcreek
Copy link
Contributor

Hmm looks like the image publishing step failed on my PR after merging:

https://github.com/sourcegraph/scip/actions/runs/9691568032/job/26743288072

should we rip that out for now?

@keynmol
Copy link
Contributor Author

keynmol commented Jun 27, 2024

I will fix that workflow, I have a working one I can just copypaste.

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