Skip to content

Commit

Permalink
Add azd devcontainer feature (#1118)
Browse files Browse the repository at this point in the history
* Adding devcontainer definition - #1095

* Update ext/devcontainer/devcontainer-feature.json

* adding workflow to publish devcontainer image

* Update ext/devcontainer/devcontainer-feature.json

* Update ext/devcontainer/README.md

* adding tests and supporting the expected folder structure

* ensuring curl is available and fixing tests

* Update ext/devcontainer/src/azd/install.sh

Co-authored-by: Daniel Jurek <djurek@microsoft.com>

* combining devcontainer workflows into a single workflow
- test jobs need to pass before deploy passes
- deploy job linked to environment for approval

* Updating based on some feedback

Turns out that the script being run was uninstall not install, whoops

* Apply suggestions from code review

Co-authored-by: hemarina <104857065+hemarina@users.noreply.github.com>

* Apply suggestions from code review

* Update ext/devcontainer/src/azd/README.md

Co-authored-by: Aaron Powell <me@aaron-powell.com>

* Update ext/devcontainer/src/azd/install.sh

Co-authored-by: Aaron Powell <me@aaron-powell.com>

* Update ext/devcontainer/src/azd/install.sh

Co-authored-by: hemarina <104857065+hemarina@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: hemarina <104857065+hemarina@users.noreply.github.com>

* Update ext/devcontainer/src/azd/devcontainer-feature.json

Co-authored-by: Matt Ellis <matt.ellis@microsoft.com>

* Update ext/devcontainer/src/azd/README.md

* add xdg-utils/version due to local test/feedback

* remove since vscode-node-azure-pack contains it

* add auto pr for documentation update

* separate release and test, add permission

* add workflow test yml

* add PAT for release tag

---------

Co-authored-by: Daniel Jurek <djurek@microsoft.com>
Co-authored-by: Victor Vazquez <vhvb1989@gmail.com>
Co-authored-by: hemarina <104857065+hemarina@users.noreply.github.com>
Co-authored-by: Matt Ellis <matt.ellis@microsoft.com>
Co-authored-by: hemarina <hemarina@microsoft.com>
  • Loading branch information
6 people committed Jul 6, 2023
1 parent 5384149 commit fa3412e
Show file tree
Hide file tree
Showing 6 changed files with 184 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/devcontainer-feature-release.yml
@@ -0,0 +1,35 @@
name: Release dev container feature image

env:
IMAGE_NAME: ${{ github.repository }}
REGISTRY: ghcr.io

on:
workflow_dispatch:

jobs:
call-workflow-test:
uses: ".github/workflows/devcontainer-feature-test.yml"

deploy:
if: ${{ github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
needs: call-workflow-test
permissions:
contents: write
packages: write
pull-requests: write
environment:
name: deploy-devcontainer-feature
steps:
- uses: actions/checkout@v3

- name: "Publish Features"
uses: devcontainers/action@v1
with:
publish-features: "true"
base-path-to-features: "./ext/devcontainer"
generate-docs: "false"

env:
GITHUB_TOKEN: ${{ secrets.PAT }}
61 changes: 61 additions & 0 deletions .github/workflows/devcontainer-feature-test.yml
@@ -0,0 +1,61 @@
name: Test dev container feature
on:
workflow_dispatch:
pull_request:
paths:
- "ext/devcontainer/**"
- ".github/workflows/devcontainer-feature-test.yml"
branches: [main]
workflow_call:

jobs:
test:
runs-on: ubuntu-latest
continue-on-error: true
strategy:
matrix:
baseImage:
[
"ubuntu:focal",
"ubuntu:jammy",
"ubuntu:bionic",
"debian:11",
"debian:10",
"mcr.microsoft.com/devcontainers/base:ubuntu",
"mcr.microsoft.com/devcontainers/base:debian",
]
steps:
- uses: actions/checkout@v3

- name: "Install latest devcontainer CLI"
run: npm install -g @devcontainers/cli

- name: "Generating tests for 'azd' against '${{ matrix.baseImage }}'"
run: devcontainer features test -f azd -i ${{ matrix.baseImage }} .
working-directory: ./ext/devcontainer

test-scenarios:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v3

- name: "Install latest devcontainer CLI"
run: npm install -g @devcontainers/cli

- name: "Testing 'azd' scenarios"
run: devcontainer features test -f azd --skip-autogenerated .
working-directory: ./ext/devcontainer

test-global:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v3

- name: "Install latest devcontainer CLI"
run: npm install -g @devcontainers/cli

- name: "Testing global scenarios"
run: devcontainer features test --global-scenarios-only .
working-directory: ./ext/devcontainer
25 changes: 25 additions & 0 deletions ext/devcontainer/src/azd/README.md
@@ -0,0 +1,25 @@
# Azure Developer CLI (azd)

Installs the [Azure Developer CLI](https://github.com/Azure/azure-dev) along with needed dependencies.

## Example Usage

```json
"features": {
"ghcr.io/azure/azure-dev/azd:1": {
"version": "stable"
}
}
```

## Options

| Options Id | Description | Type | Default Value |
|-----|-----|-----|-----|
| version | Select or enter an Azure Developer CLI version. (Available versions may vary by Linux distribution.) | string | stable |

## Customizations

### VS Code Extensions

- `ms-azuretools.azure-dev`
25 changes: 25 additions & 0 deletions ext/devcontainer/src/azd/devcontainer-feature.json
@@ -0,0 +1,25 @@
{
"id": "azd",
"version": "0.1.0",
"name": "Azure Developer CLI",
"documentationURL": "https://github.com/azure/azure-dev/tree/main/ext/devcontainer/src/azd",
"description": "Installs the Azure Developer CLI along with needed dependencies.",
"options": {
"version": {
"type": "string",
"proposals": [
"stable"
],
"default": "stable",
"description": "Select or enter an Azure Developer CLI version. (Available versions may vary by Linux distribution.)"
}
},
"customizations": {
"vscode": {
"extensions": [
"ms-azuretools.vscode-bicep",
"ms-vscode.vscode-node-azure-pack"
]
}
}
}
26 changes: 26 additions & 0 deletions ext/devcontainer/src/azd/install.sh
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
#-------------------------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

AZD_VERSION=${VERSION:-"stable"}

check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
echo "Running apt-get update..."
apt-get update -y
fi
apt-get -y install --no-install-recommends "$@"
fi
}

echo "(*) Ensuring dependencies are installed"

check_packages apt-transport-https curl ca-certificates xdg-utils
check_packages $(apt-cache search '^libicu[0-9]+$' | cut -d' ' -f1)

echo "(*) Installing Azure Developer CLI"

curl -fsSL https://aka.ms/install-azd.sh | bash -s -- --version $AZD_VERSION -a $(dpkg --print-architecture)
12 changes: 12 additions & 0 deletions ext/devcontainer/test/azd/test.sh
@@ -0,0 +1,12 @@
#!/bin/bash

set -e

# Optional: Import test library
source dev-container-features-test-lib

# Definition specific tests
check "version" azd version

# Report result
reportResults

0 comments on commit fa3412e

Please sign in to comment.