Skip to content

Commit

Permalink
add developer environment for vscode
Browse files Browse the repository at this point in the history
Problem: as a new developer it is hard to setup a local environment
Solution: provide a .devcontainer setup, including ruby, chef resources, Python, and tox, and a brief note about using the environment in the CONTRIBUTING.md
Signed-off-by: vsoch <[email protected]>
  • Loading branch information
vsoch authored and hgreebe committed Nov 13, 2023
1 parent 108d78f commit c063262
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
FROM ruby:2.7

LABEL maintainer="Amazon Web Services"

# Match the default user id for a single system so we aren't root
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=1000
ENV USERNAME=${USERNAME}
ENV USER_UID=${USER_UID}
ENV USER_GID=${USER_GID}

# Assuming extra libs could be installed to /usr/local
ENV LD_LIBRARY_PATH=/usr/local/lib

RUN apt-get update \
&& apt-get -qq install -y --no-install-recommends \
sudo \
python3-pip \
python3 && \
pip3 install tox && \
ln -s /usr/bin/python3 /usr/bin/python && \
apt-get clean

ENV CHEF_LICENSE=accept-no-persist

# Done so does not fail if missing Gemfile.lock
COPY ./Gemfile* /tmp/
RUN cd /tmp && \
bundle config set with 'style' && \
bundle install && \
curl -L https://omnitruck.cinc.sh/install.sh -o chefDownload.sh && \
chmod +x chefDownload.sh && \
./chefDownload.sh -c stable -P cinc-workstation

# Add the group and user that match our ids
RUN groupadd -g ${USER_GID} ${USERNAME} && \
adduser --disabled-password --uid ${USER_UID} --gid ${USER_GID} --gecos "" ${USERNAME} && \
echo "${USERNAME} ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers
USER $USERNAME
ENV PATH=/opt/chef-workstation/embedded/bin:$PATH
33 changes: 33 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "AWS ParallelCluster Cookbook Developer Environment",
"dockerFile": "Dockerfile",
"context": "../",

"customizations": {
"vscode": {
"settings": {
"terminal.integrated.defaultProfile.linux": "bash",

// Ensure that Python autocomplete works out of the box
"python.autoComplete.extraPaths": [
"/usr/local/lib/python3.8/site-packages"
],
"python.analysis.extraPaths": [
"/usr/local/lib/python3.8/site-packages"
]
},
// Note to Flux Developers! We can add extensions here that you like
"extensions": [
"ms-python.python", // Python support
"GitHub.vscode-pull-request-github" // manage and review PRs
]
}
},
"features": {
"ghcr.io/devcontainers/features/github-cli:1": {
"version": "latest"
}
},
// Needed for git security feature (this assumes you locally cloned to flux-core)
"postStartCommand": "git config --global --add safe.directory /workspaces/aws-parallelcluster-cookbook"
}
35 changes: 35 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,41 @@ GitHub provides additional document on [forking a repository](https://help.githu
Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels ((enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any ['help wanted'](https://github.com/aws/aws-parallelcluster-cookbook/labels/help%20wanted) issues is a great place to start.


## VSCode Developer Environment

We provide a [.devcontainer](../.devcontainer) environment that you can open in VSCode, either automatically via the popup that will
appear in the bottom right, or the command palette for DevContainer -> Reopen in container. The image comes with ruby 2.7 and dependencies installed and then you will shell in as the VSCode user (uid 1000) and can test style, run Python tests:

```bash
cookstyle .
```

or run Python tests (we have version 3.9 in the container)

```bash
tox -e py39-nocov
```

Or go to any of the cookbooks directories and run ChefSpec

```bash
cd cookbooks/aws-parallelcluster-awsbatch
chef exec rspec
cd cookbooks/aws-parallelcluster-computefleet
chef exec rspec
cd cookbooks/aws-parallelcluster-environment
chef exec rspec
cd cookbooks/aws-parallelcluster-platform
chef exec rspec
cd cookbooks/aws-parallelcluster-shared
chef exec rspec
cd cookbooks/aws-parallelcluster-slurm
chef exec rspec
```

Although the uid of 1000 (for the vscode user) likely matches your system user, we recommend that you commit and otherwise interact with git from the outside,
as likely your system credentials are in your actual user home.

## Code of Conduct
This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
Expand Down

0 comments on commit c063262

Please sign in to comment.