Skip to content

Latest commit

 

History

History
76 lines (62 loc) · 4.17 KB

File metadata and controls

76 lines (62 loc) · 4.17 KB

devcontainers

This Repo

This repo is based on template-starter for building and publishing custom VSCode devcontainer features. Each custom feature is described by the devcontainer specification.

See also devcontainer org and CLI.

Using a Custom devcontainer Feature in Your Project Repo

An example .devcontainer/devcontainer.json is included in this repo. Add it to your project repo to use the features listed in this project. The base image is chosen from Microsoft's devcontainer repository here.

Custom features available:

  • Opencode. The opencode devcontainer will look for opencode.json config in your project root folder as described here. An example opencode-config-example.json config file is included that you can rename and edit.
  • TeX Live. Installs TeX Live, a comprehensive TeX distribution with LaTeX support.
  • APT Packages. Installs arbitrary apt-get Ubuntu/Debian packages.

Project Structure

devcontainers/
├── .devcontainer/                          # Used for testing features in local dev environment, not published
│   └── devcontainer.json                   # Add to your own repo in order to specify features in your own devcontainer
├── .github                             
│   └── workflows                       
│       ├── publish.yml                     # Publish to container registry
│       ├── test.yaml                       # Test 
│       └── validate.yaml                   # Validate for PRs
├── src                                     # Each folder in here is a separate feature, published
│   ├── featureName
│   │   ├── devcontainer-feature.json       # Feature description
│   │   └── install.sh                      # Entry point of container
│   │   └── README.md                       # Feature documentation
|   ├── ...
│   │   ├── devcontainer-feature.json
│   │   └── install.sh
│   │   └── README.md                       
├── test                                    # Each folder in here tests a separate feature
│   ├── opencode
│   │   ├── common_scenario_test.json       # Common scenario test script
│   │   └── latest-not-specified-version.sh # Scenario: check a 'latest' version is installed when no option specified
│   │   ├── latest-specified-version.json   # Scenario: check a 'latest' version is installed when 'latest' is specified
│   │   └── pinned-version.sh               # Scenario: check a specific version is installed
│   │   ├── scenarios.json                  # Scenarios spec: Set up multiple scenarios, each testing different feature option value
│   │   └── test.sh                         # Entry point for regular tests (required even if running scenario tests)
|   ├── ...
│   │   ├── scenarios.json
│   │   └── test.sh
...

Local Feature Development

Test Dependencies

The following installs node via nvm as described here.

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash    # installs nvm (Node Version Manager) v0.40.1
$ nvm -v

Reopening the terminal, nvm will read .nvmrc file to check the required node version.

$ nvm install        # download and install Node.js specified in .nvmrc (restart the terminal first)
$ node -v            # verifies the right Node.js version is in the environment
$ npm -v             # verifies the right npm version is in the environment

Running Tests

Make sure all shell test scripts are executable chmod +x "${SHELL_SCRIPT}".

$ npm i
$ npm run test:individual   # Runs all `test/*/test.sh` tests
$ npm run test:scenarios    # Runs all `test/*/scenarios.json` tests