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
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/node_modules
keynmol marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 3 additions & 12 deletions .github/workflows/protobuf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,12 @@ on:
- 'buf**'
- '.tool-versions'
- 'dev/proto-generate.sh'
- 'dev/proto-generate-in-docker.sh'
- 'Dockerfile.bindings'

jobs:
protoc-gen-up-to-date:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Haskell
uses: haskell/actions/setup@v2
with:
ghc-version: '8.10'
cabal-version: 'latest'
- uses: ./.github/actions/asdf
with:
js: true
rust: true
golang: true
- run: ./dev/proto-generate.sh
- run: git diff --exit-code
- run: ./dev/proto-generate-in-docker.sh
keynmol marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 2 additions & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -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)

shellcheck 0.7.1
yarn 1.22.17
rust 1.71.0
python 3.11.9
10 changes: 10 additions & 0 deletions Development.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,20 @@
## Code generation

1. Regenerating definitions after changing the schema in [scip.proto](./scip.proto).

If you have **asdf** setup on your machine, you can use the binding generation script directly:

```
./dev/proto-generate.sh
```

For the Haskell bindings, see `bindings/haskell/README.md`.

You can also run the same script in a pre-configured Docker environment,
by running `./dev/proto-generate-in-docker.sh` - this command will
build the environment and run ./dev/proto-generate.sh script. The only
dependency you need is Docker.
keynmol marked this conversation as resolved.
Show resolved Hide resolved

2. Regenerating snapshots after making changes to the CLI.
```
go test ./cmd/scip -update-snapshots
Expand Down
45 changes: 45 additions & 0 deletions Dockerfile.bindings
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
FROM ubuntu@sha256:19478ce7fc2ffbce89df29fea5725a8d12e57de52eb9ea570890dc5852aac1ac
keynmol marked this conversation as resolved.
Show resolved Hide resolved

ENV DEBIAN_FRONTEND noninteractive

RUN apt-get update -q && apt-get install -y git curl xz-utils tar gpg build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev \
libncursesw5-dev tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev \
libffi8 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5 pkg-config

RUN adduser --shell /bin/bash --home /asdf --disabled-password asdf
ENV PATH="${PATH}:/asdf/.asdf/shims:/asdf/.asdf/bin"

USER asdf
RUN git clone --depth 1 https://github.com/asdf-vm/asdf.git $HOME/.asdf && \
echo '. $HOME/.asdf/asdf.sh' >> $HOME/.bashrc && \
echo '. $HOME/.asdf/asdf.sh' >> $HOME/.profile

RUN . ~/.bashrc

# YOLO
RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

ENV PATH="${PATH}:/asdf/.ghcup/bin"

RUN asdf plugin add nodejs && \
asdf plugin add golang && \
asdf plugin add shellcheck && \
asdf plugin add yarn && \
asdf plugin add python && \
asdf plugin add rust

COPY .tool-versions .

RUN asdf install && \
# Pre-fetch Haskell dependencies as they take the longest time by far
# TODO(anton): run the proto-generate.sh script during the build time to
# pre-fecth all dependencies. I attempted to do so but ran into issues
# with Yarn
cabal install proto-lens-protoc-0.8.0.1 ghc-source-gen-0.4.5.0

WORKDIR /src

ENTRYPOINT ["./dev/proto-generate.sh"]


253 changes: 69 additions & 184 deletions bindings/haskell/src/Proto/Scip.hs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion cmd/scip/tests/reprolang/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"nan": "^2.15.0"
},
"devDependencies": {
"tree-sitter-cli": "^0.20.4"
"tree-sitter-cli": "^0.20.8"
}
}
10 changes: 10 additions & 0 deletions dev/proto-generate-in-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env bash

set -xeuo pipefail

cd "$(dirname "${BASH_SOURCE[0]}")/.." # cd to repo root dir

IMAGE_NAME="sourcegraph/scip-bindings-env"

docker build . -t $IMAGE_NAME -f Dockerfile.bindings
docker run -v $(pwd):/src $IMAGE_NAME
2 changes: 1 addition & 1 deletion dev/proto-generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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...

# buf requires the generator to be named protoc-gen-*
ln -sfv "$PWD/.bin/proto-lens-protoc" "$PWD/.bin/protoc-gen-haskell"
PATH="$PWD/.bin:$PATH"
Expand Down
Loading