-
Notifications
You must be signed in to change notification settings - Fork 24
chore: add devcontainer contributor workflow [DX-822] #209
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| ARG JAVA_VERSION=8 | ||
| FROM eclipse-temurin:${JAVA_VERSION}-jdk-jammy | ||
|
|
||
| RUN groupadd --gid 1000 vscode \ | ||
| && useradd --uid 1000 --gid 1000 --create-home --shell /bin/bash vscode \ | ||
| && apt-get update \ | ||
| && apt-get install -y --no-install-recommends curl git openssh-client \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "name": "contentful-management.java", | ||
| "build": { | ||
| "dockerfile": "Dockerfile", | ||
| "context": "..", | ||
| "args": { | ||
| "JAVA_VERSION": "${localEnv:JAVA_VERSION:8}" | ||
| } | ||
| }, | ||
| "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", | ||
| "remoteUser": "vscode", | ||
| "postCreateCommand": "./mvnw -B -q -DskipTests dependency:go-offline", | ||
| "customizations": { | ||
| "vscode": { | ||
| "extensions": [ | ||
| "redhat.java" | ||
| ] | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [master] | ||
| pull_request: | ||
| branches: [master] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Test (Java 8) | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v5 | ||
|
|
||
| - name: Install devcontainer CLI | ||
| run: npm install -g @devcontainers/cli@0 | ||
|
|
||
| - name: Run tests in dev container | ||
| env: | ||
| JAVA_VERSION: "8" | ||
| run: | | ||
| devcontainer up --workspace-folder . | ||
| devcontainer exec --workspace-folder . bash -lc "./mvnw -B test" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Contributing | ||
|
|
||
| Thanks for helping improve `contentful-management.java`. | ||
|
|
||
| ## Development with Dev Containers | ||
|
|
||
| This repository includes a `.devcontainer` configuration for a reproducible local setup. GitHub Actions uses the same devcontainer configuration for CI. | ||
|
|
||
| ### Visual Studio Code | ||
|
|
||
| Open the repository in Visual Studio Code, install the Dev Containers extension if needed, then run `Dev Containers: Reopen in Container`. Wait for the container build and post-create setup to finish. | ||
|
|
||
| ### Terminal or other editors | ||
|
|
||
| Install Docker and the Dev Container CLI (`npm install -g @devcontainers/cli`). From the repository root, run: | ||
|
|
||
| ```bash | ||
| devcontainer up --workspace-folder . | ||
| devcontainer exec --workspace-folder . bash | ||
| ``` | ||
|
|
||
| ### Verify the environment | ||
|
|
||
| ```bash | ||
| ./mvnw -B test | ||
| ``` | ||
|
|
||
| ## Pull Requests | ||
|
|
||
| 1. Fork the repository and create a branch for your change. | ||
| 2. Run the relevant checks from the dev container. | ||
| 3. Open a pull request with a short summary of the change and any follow-up context. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just out of curiosity, why are the apt-get command different across different dev containers? This repo goes as far as setting up a new group/user, is that specific to the java implementation?
https://github.com/contentful/contentful.rb/pull/274/changes & https://github.com/contentful/contentful-management.rb/pull/278/changes
https://github.com/contentful/contentful.net/pull/394/changes
Uh oh!
There was an error while loading. Please reload this page.
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.
Good question - that's a consequence of the base image choice, not something Maven or the Java SDK itself specifically needed.
I used that one because Mircrosoft doesn't publish a Java 8 version of the base devcontainer image. That one I needed to use instead is pretty minimal, and unlike the richer Microsoft devcontainer images, it does not already give us (1) a vscode user, and (2) common contributor tools like curl, git, and openssh-client.
That’s why the Dockerfile sets those things up by itself.