Skip to content

Commit 76a272e

Browse files
authored
Dockerised binding regeneration (#257)
1 parent 6296669 commit 76a272e

19 files changed

+453
-468
lines changed

.dockerignore

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This file should be kept in sync with .gitignore
2+
3+
# Binaries for programs and plugins
4+
*.exe
5+
*.exe~
6+
*.dll
7+
*.so
8+
*.dylib
9+
10+
# Editor directories
11+
.idea/
12+
.vscode/
13+
14+
# Test binary, built with `go test -c`
15+
*.test
16+
17+
# CLI binary
18+
/scip
19+
20+
# Output of the go coverage tool, specifically when used with LiteIDE
21+
*.out
22+
23+
**/node_modules/
24+
.bin/
25+
**/target/
26+
27+
# Dependency directories (remove the comment below to include it)
28+
# vendor/
29+
dist-newstyle/
+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# If this workflow stops working, first consult the documentation page where it was copied from.
2+
# https://docs.github.com/en/actions/publishing-packages/publishing-docker-images#publishing-images-to-github-packages
3+
4+
name: Create and publish a Docker image for bindings build environment
5+
6+
# Configures this workflow to run every time a change is pushed to the branch called `release`.
7+
on:
8+
push:
9+
branches: ['main']
10+
11+
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
12+
env:
13+
REGISTRY: ghcr.io
14+
IMAGE_NAME: sourcegraph/scip-bindings-env
15+
16+
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
17+
jobs:
18+
build-and-push-image:
19+
runs-on: ubuntu-latest
20+
# Sets the permissions granted to the `GITHUB_TOKEN` for the actions in this job.
21+
permissions:
22+
contents: read
23+
packages: write
24+
attestations: write
25+
id-token: write
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
30+
- name: Set up QEMU
31+
uses: docker/setup-qemu-action@v3
32+
33+
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
34+
- name: Log in to the Container registry
35+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
36+
with:
37+
registry: ${{ env.REGISTRY }}
38+
username: ${{ github.actor }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
40+
41+
# This step uses [docker/metadata-action](https://github.com/docker/metadata-action#about) to extract tags and labels that will be applied to the specified image. The `id` "meta" allows the output of this step to be referenced in a subsequent step. The `images` value provides the base name for the tags and labels.
42+
- name: Extract metadata (tags, labels) for Docker
43+
id: meta
44+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
45+
with:
46+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
47+
tags: |
48+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
49+
50+
# This step uses the `docker/build-push-action` action to build the image, based on your repository's `Dockerfile`. If the build succeeds, it pushes the image to GitHub Packages.
51+
# It uses the `context` parameter to define the build's context as the set of files located in the specified path. For more information, see "[Usage](https://github.com/docker/build-push-action#usage)" in the README of the `docker/build-push-action` repository.
52+
# It uses the `tags` and `labels` parameters to tag and label the image with the output from the "meta" step.
53+
- name: Build and push Docker image
54+
id: push
55+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
56+
with:
57+
file: dev/Dockerfile.bindings
58+
push: true
59+
tags: ${{ steps.meta.outputs.tags }}
60+
labels: ${{ steps.meta.outputs.labels }}
61+
platforms: linux/amd64,linux/arm64
62+
63+
# This step generates an artifact attestation for the image, which is an unforgeable statement about where and how it was built. It increases supply chain security for people who consume the image. For more information, see "[AUTOTITLE](/actions/security-guides/using-artifact-attestations-to-establish-provenance-for-builds)."
64+
- name: Generate artifact attestation
65+
uses: actions/attest-build-provenance@v1
66+
with:
67+
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
68+
subject-digest: ${{ steps.push.outputs.digest }}
69+
push-to-registry: true
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Generated code is up to date
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '.github/workflows/**'
7+
- 'docs/**'
8+
- 'bindings/**'
9+
- 'scip.proto'
10+
- 'buf**'
11+
- '.tool-versions'
12+
- 'dev/proto-generate.sh'
13+
- 'dev/proto-generate-in-docker.sh'
14+
- 'Dockerfile.bindings'
15+
- 'cmd/scip/tests/reprolang/**'
16+
17+
jobs:
18+
gen-up-to-date:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
- name: Log in to the Container registry
23+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
24+
with:
25+
registry: ghcr.io
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- run: docker pull ghcr.io/sourcegraph/scip-bindings-env:latest || echo "no suitable cache"
30+
31+
- name: Regenerate protobuf bindings and reprolang parser
32+
run: |
33+
# We're changing the owner of the checkout folder to a particular user id,
34+
# matching the user id of `asdf` user we create inside the docker container.
35+
sudo chown -R 1001:1001 . && ./dev/generate-all-in-docker.sh
36+
37+
- run: git diff --exit-code

.github/workflows/protobuf.yml

-30
This file was deleted.

.github/workflows/reprolang.yml

-18
This file was deleted.

.tool-versions

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
golang 1.19.10
2-
nodejs 16.7.0
2+
nodejs 16.20.2
33
shellcheck 0.7.1
44
yarn 1.22.17
55
rust 1.71.0
6+
python 3.11.9

Development.md

+9-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,15 @@
2727
## Code generation
2828

2929
1. Regenerating definitions after changing the schema in [scip.proto](./scip.proto).
30-
```
31-
./dev/proto-generate.sh
32-
```
33-
For the Haskell bindings, see `bindings/haskell/README.md`.
30+
31+
`./dev/generate-all-in-docker.sh`
32+
33+
We provide a script that sets up the correct build environment in Docker
34+
and runs the necessary regeneration steps.
35+
36+
Both the proto bindings and reprolang parser are generated.
37+
The only dependency you need is Docker.
38+
3439
2. Regenerating snapshots after making changes to the CLI.
3540
```
3641
go test ./cmd/scip -update-snapshots

0 commit comments

Comments
 (0)