From 7b935b6bef4c665b37b2595b80566a5359fc0a49 Mon Sep 17 00:00:00 2001 From: Dan Moseley Date: Thu, 20 Feb 2025 20:41:37 -0700 Subject: [PATCH] feature --- .devcontainer/devcontainer.json | 25 ++++++++ .github/workflows/release.yaml | 47 ++++++++++++++ .github/workflows/test.yaml | 58 +++++++++++++++++ .github/workflows/validate.yml | 16 +++++ CODE-OF-CONDUCT.md | 5 ++ CODE_OF_CONDUCT.md | 9 --- LICENSE | 21 ------ LICENSE.TXT | 23 +++++++ README.md | 7 +- SECURITY.md | 18 +++--- src/dotnetaspire/README.md | 64 +++++++++++++++++++ src/dotnetaspire/devcontainer-feature.json | 42 ++++++++++++ src/dotnetaspire/install.sh | 49 ++++++++++++++ test/dotnetaspire/dotnet_env.sh | 4 ++ .../install_dotnetaspire_exact_version.sh | 1 + ...stall_dotnetaspire_latest_daily_version.sh | 1 + .../install_dotnetaspire_latest_version.sh | 1 + test/dotnetaspire/scenarios.json | 26 ++++++++ test/dotnetaspire/test.sh | 24 +++++++ 19 files changed, 399 insertions(+), 42 deletions(-) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .github/workflows/release.yaml create mode 100644 .github/workflows/test.yaml create mode 100644 .github/workflows/validate.yml create mode 100644 CODE-OF-CONDUCT.md delete mode 100644 CODE_OF_CONDUCT.md delete mode 100644 LICENSE create mode 100644 LICENSE.TXT create mode 100644 src/dotnetaspire/README.md create mode 100644 src/dotnetaspire/devcontainer-feature.json create mode 100644 src/dotnetaspire/install.sh create mode 100644 test/dotnetaspire/dotnet_env.sh create mode 100644 test/dotnetaspire/install_dotnetaspire_exact_version.sh create mode 100644 test/dotnetaspire/install_dotnetaspire_latest_daily_version.sh create mode 100644 test/dotnetaspire/install_dotnetaspire_latest_version.sh create mode 100644 test/dotnetaspire/scenarios.json create mode 100644 test/dotnetaspire/test.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..ad4c73b --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,25 @@ +{ + "image": "mcr.microsoft.com/devcontainers/javascript-node:1-20-bookworm", + "customizations": { + "vscode": { + "settings": { + "json.schemas": [ + { + "fileMatch": [ + "*/devcontainer-feature.json" + ], + "url": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainerFeature.schema.json" + } + ] + }, + "extensions": [ + "mads-hartmann.bash-ide-vscode" + ] + } + }, + "features": { + "ghcr.io/devcontainers/features/docker-in-docker:2": {} + }, + "remoteUser": "node", + "updateContentCommand": "npm install -g @devcontainers/cli" +} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..57572c7 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,47 @@ +name: "Release dev container features & Generate Documentation" +on: + workflow_dispatch: + +jobs: + deploy: + if: ${{ github.ref == 'refs/heads/main' }} + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + packages: write + steps: + - uses: actions/checkout@v4 + + - name: "Publish Features" + uses: devcontainers/action@v1 + with: + publish-features: "true" + base-path-to-features: "./src" + generate-docs: "true" + + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Create PR for Documentation + id: push_image_info + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -e + echo "Start." + # Configure git and Push updates + git config --global user.email github-actions[bot]@users.noreply.github.com + git config --global user.name github-actions[bot] + git config pull.rebase false + branch=automated-documentation-update-$GITHUB_RUN_ID + git checkout -b $branch + message='Automated documentation update' + # Add / update and commit + git add */**/README.md + git commit -m 'Automated documentation update [skip ci]' || export NO_UPDATES=true + # Push + if [ "$NO_UPDATES" != "true" ] ; then + git push origin "$branch" + gh pr create --title "$message" --body "$message" + fi diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..4033ca9 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,58 @@ +name: "CI - Test Features" +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + test-autogenerated: + runs-on: ubuntu-latest + continue-on-error: true + strategy: + matrix: + features: + - color + - hello + baseImage: + - debian:latest + - ubuntu:latest + - mcr.microsoft.com/devcontainers/base:ubuntu + steps: + - uses: actions/checkout@v4 + + - name: "Install latest devcontainer CLI" + run: npm install -g @devcontainers/cli + + - name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'" + run: devcontainer features test --skip-scenarios -f ${{ matrix.features }} -i ${{ matrix.baseImage }} . + + test-scenarios: + runs-on: ubuntu-latest + continue-on-error: true + strategy: + matrix: + features: + - color + - hello + steps: + - uses: actions/checkout@v4 + + - name: "Install latest devcontainer CLI" + run: npm install -g @devcontainers/cli + + - name: "Generating tests for '${{ matrix.features }}' scenarios" + run: devcontainer features test -f ${{ matrix.features }} --skip-autogenerated --skip-duplicated . + + test-global: + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/checkout@v4 + + - name: "Install latest devcontainer CLI" + run: npm install -g @devcontainers/cli + + - name: "Testing global scenarios" + run: devcontainer features test --global-scenarios-only . diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 0000000..863418e --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,16 @@ +name: "Validate devcontainer-feature.json files" +on: + workflow_dispatch: + pull_request: + +jobs: + validate: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: "Validate devcontainer-feature.json files" + uses: devcontainers/action@v1 + with: + validate-only: "true" + base-path-to-features: "./src" diff --git a/CODE-OF-CONDUCT.md b/CODE-OF-CONDUCT.md new file mode 100644 index 0000000..0fd65e9 --- /dev/null +++ b/CODE-OF-CONDUCT.md @@ -0,0 +1,5 @@ +# Code of Conduct + +This project has adopted the code of conduct defined by the Contributor Covenant +to clarify expected behavior in our community. +For more information, see the [.NET Foundation Code of Conduct](https://dotnetfoundation.org/code-of-conduct). diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index f9ba8cf..0000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,9 +0,0 @@ -# Microsoft Open Source Code of Conduct - -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). - -Resources: - -- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/) -- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) -- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 4f0d38c..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - MIT License - - Copyright (c) .NET Foundation. All rights reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE diff --git a/LICENSE.TXT b/LICENSE.TXT new file mode 100644 index 0000000..984713a --- /dev/null +++ b/LICENSE.TXT @@ -0,0 +1,23 @@ +The MIT License (MIT) + +Copyright (c) .NET Foundation and Contributors + +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 07cd509..af93af9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ -# Contributing -This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. +# .NET Aspire (dotnetaspire) + +This repo builds, tests and publishes a cevcontainer feature that installs .NET Aspire and if necessary the .NET (dotnet) that it depends on. Options are provided to choose a different version or additional versions. + +See [README.md in the subfolder](src/dotnetaspire/README.md) for more information. \ No newline at end of file diff --git a/SECURITY.md b/SECURITY.md index b3c89ef..86614dd 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,20 +1,18 @@ - +# Security -## Security +Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). -Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet) and [Xamarin](https://github.com/xamarin). - -If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/security.md/definition), please report it to us as described below. +If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below. ## Reporting Security Issues **Please do not report security vulnerabilities through public GitHub issues.** -Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/security.md/msrc/create-report). +Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report). -If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/security.md/msrc/pgp). +If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc). -You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). +You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc). Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: @@ -28,7 +26,7 @@ Please include the requested information listed below (as much as you can provid This information will help us triage your report more quickly. -If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/security.md/msrc/bounty) page for more details about our active programs. +If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs. ## Preferred Languages @@ -36,6 +34,6 @@ We prefer all communications to be in English. ## Policy -Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/security.md/cvd). +Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd). diff --git a/src/dotnetaspire/README.md b/src/dotnetaspire/README.md new file mode 100644 index 0000000..8f6f88e --- /dev/null +++ b/src/dotnetaspire/README.md @@ -0,0 +1,64 @@ + +# .NET Aspire (dotnetaspire) + +This Feature installs .NET Aspire and if necessary the .NET (dotnet) that it depends on. Options are provided to choose a different version or additional versions. + +## OS Support + +This Feature should work on recent versions of Debian/Ubuntu-based distributions that support .NET and have the `apt` package manager installed + +`bash` is required to execute the `install.sh` script. + +## Example Usage + +```json +"features": { + "ghcr.io/devcontainers/features/dotnetaspire:1": {} +} +``` + +## Options + +| Options Id | Description | Type | Default Value | +|-----|-----|-----|-----| +| version | .NET Aspire version. Use 'latest' for the latest supported version, '9.0' for the 9.0 version, 'X.Y' or 'X.Y.Z' for a specific version, or 'latest-daily' for the latest unsupported build. | string | latest | + +## Customizations + +### VS Code Extensions + +- `ms-dotnettools.csdevkit` + +## Configuration examples + +Installing only the latest .NET Aspire version (the default). + +``` jsonc +"features": { + "ghcr.io/devcontainers/features/dotnetaspire:1": "latest" // or "" or {} +} +``` + +Installing .NET Aspire version 9.0. + +``` jsonc +"features": { + "ghcr.io/devcontainers/features/dotnetaspire:1": "9.0" // or "" or {} +} +``` + +Installing the latest .NET Aspire unsupported build. + +``` jsonc +"features": { + "ghcr.io/devcontainers/features/dotnetaspire:1": "latest-daily" // or "" or {} +} +``` + + +## OS Support + +This Feature should work on recent versions of Debian/Ubuntu-based distributions with the `apt` package manager installed. + +`bash` is required to execute the `install.sh` script. + diff --git a/src/dotnetaspire/devcontainer-feature.json b/src/dotnetaspire/devcontainer-feature.json new file mode 100644 index 0000000..5c5f0ca --- /dev/null +++ b/src/dotnetaspire/devcontainer-feature.json @@ -0,0 +1,42 @@ +{ + "id": "dotnetaspire", + "version": "1.0.0", + "name": ".NET Aspire", + "documentationURL": "https://github.com/devcontainers/features/tree/main/src/dotnetaspire", + "description": "Installs .NET Aspire. See https://aka.ms/dotnetaspire", + "options": { + "version": { + "type": "string", + "proposals": [ + "latest daily", + "latest", + "9.0", + ], + "default": "9.0", + "description": "Select or enter a .NET Aspire version. Use 'latest' for the latest supported version, '9.0' for the 9.0 version, 'X.Y' or 'X.Y.Z' for a specific version, or 'latest-daily' for the latest unsupported build." + }, + }, + "customizations": { + "vscode": { + "extensions": [ + "ms-dotnettools.csdevkit", + "ms-azuretools.vscode-bicep", + "GitHub.copilot-chat", + "GitHub.copilot" + ], + "settings": { + "remote.autoForwardPorts": true, + "remote.autoForwardPortsSource": "hybrid", + "remote.otherPortsAttributes": { + "onAutoForward": "ignore" + } + } + } + }, + "dependsOn": { + "ghcr.io/devcontainers/features/dotnet": { + "version": "8.0", + "additionalVersions": "9.0" + } + } +} diff --git a/src/dotnetaspire/install.sh b/src/dotnetaspire/install.sh new file mode 100644 index 0000000..ac8bf34 --- /dev/null +++ b/src/dotnetaspire/install.sh @@ -0,0 +1,49 @@ +#!/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. +#------------------------------------------------------------------------------------------------------------- +# +# Docs: https://github.com/devcontainers/features/tree/main/src/dotnet +# Maintainer: The .NET Aspire team at https://github.com/dotnet/aspire + +set -e + +# default to latest if not specified +VERSION="${VERSION:-"latest"}" + +if [[ ! $VERSION =~ ^(9\.0|latest|latest-daily)$ ]]; then + echo "Error: VERSION must be either '9.0', '9.0.0', 'latest', or 'latest-daily' not: '$VERSION'." + exit 1 +fi + +if [[ $VERSION =~ ^(9\.0|9\.0\.0|latest)$ ]]; then + VERSION="9.0.0" +fi + +echo "Activating feature '.NET Aspire' version: $VERSION" + +# Before .NET Aspire 9.0 install required `dotnet workload`: this is no longer necessary, as Aspire is +# installed when restoring Aspire projects. It's only necessary to install the appropriate version of the templates. + + +if [[ $VERSION =~ ^(9\.0\.0)$ ]]; then + dotnet new install Aspire.ProjectTemplates::$VERSION +else + # https://github.com/dotnet/aspire/blob/main/docs/using-latest-daily.md + dotnet nuget add source --name dotnet9 https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json + + # If you use Package Source Mapping, you'll also need to add the following mappings to your NuGet.config + # + # + # + # + # + # + # + + dotnet new install Aspire.ProjectTemplates::*-* --force +fi + +echo "... done activating feature '.NET Aspire' version: $VERSION" diff --git a/test/dotnetaspire/dotnet_env.sh b/test/dotnetaspire/dotnet_env.sh new file mode 100644 index 0000000..37b14ea --- /dev/null +++ b/test/dotnetaspire/dotnet_env.sh @@ -0,0 +1,4 @@ +#!/bin/bash +export DOTNET_NOLOGO=true +export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true +export DOTNET_GENERATE_ASPNET_CERTIFICATE=false \ No newline at end of file diff --git a/test/dotnetaspire/install_dotnetaspire_exact_version.sh b/test/dotnetaspire/install_dotnetaspire_exact_version.sh new file mode 100644 index 0000000..f1f641a --- /dev/null +++ b/test/dotnetaspire/install_dotnetaspire_exact_version.sh @@ -0,0 +1 @@ +#!/usr/bin/env bash diff --git a/test/dotnetaspire/install_dotnetaspire_latest_daily_version.sh b/test/dotnetaspire/install_dotnetaspire_latest_daily_version.sh new file mode 100644 index 0000000..f1f641a --- /dev/null +++ b/test/dotnetaspire/install_dotnetaspire_latest_daily_version.sh @@ -0,0 +1 @@ +#!/usr/bin/env bash diff --git a/test/dotnetaspire/install_dotnetaspire_latest_version.sh b/test/dotnetaspire/install_dotnetaspire_latest_version.sh new file mode 100644 index 0000000..f1f641a --- /dev/null +++ b/test/dotnetaspire/install_dotnetaspire_latest_version.sh @@ -0,0 +1 @@ +#!/usr/bin/env bash diff --git a/test/dotnetaspire/scenarios.json b/test/dotnetaspire/scenarios.json new file mode 100644 index 0000000..8865d54 --- /dev/null +++ b/test/dotnetaspire/scenarios.json @@ -0,0 +1,26 @@ +{ + "install_dotnetaspire_exact_version": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "dotnetaspire": { + "version": "9.0" + } + } + }, + "install_dotnetaspire_latest_version": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "dotnetaspire": { + "version": "latest" + } + } + }, + "install_dotnetaspire_latest_daily_version": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "features": { + "dotnetaspire": { + "version": "latest-daily" + } + } + } +} \ No newline at end of file diff --git a/test/dotnetaspire/test.sh b/test/dotnetaspire/test.sh new file mode 100644 index 0000000..dd421e3 --- /dev/null +++ b/test/dotnetaspire/test.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -e + +# Run tests with `devcontainer features test -f dotnetaspire` in the parent of the src and test folders. + +source dev-container-features-test-lib +source dotnet_env.sh + +check "dotnet is installed in DOTNET_ROOT and execute permission is granted" \ +test -x "$DOTNET_ROOT/dotnet" + +check "dotnet 8.0 is installed" \ +test "$($DOTNET_ROOT/dotnet --info | grep '8.0.')" + +check "dotnet 9.0 is installed" \ +test "$($DOTNET_ROOT/dotnet --info | grep '9.0.')" + +check "dotnetaspire templates are installed" \ +test "$DOTNET_ROOT/dotnet new aspire" + +# There isn't currently a good way to check what version of the templates was installed. + +reportResults \ No newline at end of file