Compare commits
5 commits
main
...
joshspicer
Author | SHA1 | Date | |
---|---|---|---|
|
eaa0aff422 | ||
|
18db2f09c7 | ||
|
883c99bc1e | ||
|
dadaffc450 | ||
|
348ee69aaa |
19 changed files with 202 additions and 72 deletions
151
.github/workflows/test-pr.yaml
vendored
151
.github/workflows/test-pr.yaml
vendored
|
@ -3,81 +3,94 @@ on:
|
|||
pull_request:
|
||||
|
||||
jobs:
|
||||
detect-changes:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
features: ${{ steps.filter.outputs.changes }}
|
||||
steps:
|
||||
- uses: dorny/paths-filter@v2
|
||||
id: filter
|
||||
with:
|
||||
filters: |
|
||||
anaconda: ./**/anaconda/**
|
||||
aws-cli: ./**/aws-cli/**
|
||||
azure-cli: ./**/azure-cli/**
|
||||
common-utils: ./**/common-utils/**
|
||||
conda: ./**/conda/**
|
||||
desktop-lite: ./**/desktop-lite/**
|
||||
docker-from-docker: ./**/docker-from-docker/**
|
||||
docker-in-docker: ./**/docker-in-docker/**
|
||||
dotnet: ./**/dotnet/**
|
||||
git: ./**/git/**
|
||||
git-lfs: ./**/git-lfs/**
|
||||
github-cli: ./**/github-cli/**
|
||||
go: ./**/go/**
|
||||
hugo: ./**/hugo/**
|
||||
java: ./**/java/**
|
||||
kubectl-helm-minikube: ./**/kubectl-helm-minikube/**
|
||||
node: ./**/node/**
|
||||
nvidia-cuda: ./**/nvidia-cuda/**
|
||||
oryx: ./**/oryx/**
|
||||
php: ./**/php/**
|
||||
powershell: ./**/powershell/**
|
||||
python: ./**/python/**
|
||||
ruby: ./**/ruby/**
|
||||
rust: ./**/rust/**
|
||||
sshd: ./**/sshd/**
|
||||
terraform: ./**/terraform/**
|
||||
nix: ./**/nix/**
|
||||
# detect-changes:
|
||||
# runs-on: ubuntu-latest
|
||||
# outputs:
|
||||
# features: ${{ steps.filter.outputs.changes }}
|
||||
# steps:
|
||||
# - uses: dorny/paths-filter@v2
|
||||
# id: filter
|
||||
# with:
|
||||
# filters: |
|
||||
# anaconda: ./**/anaconda/**
|
||||
# aws-cli: ./**/aws-cli/**
|
||||
# azure-cli: ./**/azure-cli/**
|
||||
# common-utils: ./**/common-utils/**
|
||||
# conda: ./**/conda/**
|
||||
# desktop-lite: ./**/desktop-lite/**
|
||||
# docker-from-docker: ./**/docker-from-docker/**
|
||||
# docker-in-docker: ./**/docker-in-docker/**
|
||||
# dotnet: ./**/dotnet/**
|
||||
# git: ./**/git/**
|
||||
# git-lfs: ./**/git-lfs/**
|
||||
# github-cli: ./**/github-cli/**
|
||||
# go: ./**/go/**
|
||||
# hugo: ./**/hugo/**
|
||||
# java: ./**/java/**
|
||||
# kubectl-helm-minikube: ./**/kubectl-helm-minikube/**
|
||||
# node: ./**/node/**
|
||||
# nvidia-cuda: ./**/nvidia-cuda/**
|
||||
# oryx: ./**/oryx/**
|
||||
# php: ./**/php/**
|
||||
# powershell: ./**/powershell/**
|
||||
# python: ./**/python/**
|
||||
# ruby: ./**/ruby/**
|
||||
# rust: ./**/rust/**
|
||||
# sshd: ./**/sshd/**
|
||||
# terraform: ./**/terraform/**
|
||||
# nix: ./**/nix/**
|
||||
|
||||
test:
|
||||
needs: [detect-changes]
|
||||
# test:
|
||||
# needs: [detect-changes]
|
||||
# runs-on: ubuntu-latest
|
||||
# continue-on-error: true
|
||||
# strategy:
|
||||
# matrix:
|
||||
# features: ${{ fromJSON(needs.detect-changes.outputs.features) }}
|
||||
# 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@v2
|
||||
|
||||
# - 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:
|
||||
# needs: [detect-changes]
|
||||
# runs-on: ubuntu-latest
|
||||
# continue-on-error: true
|
||||
# strategy:
|
||||
# matrix:
|
||||
# features: ${{ fromJSON(needs.detect-changes.outputs.features) }}
|
||||
# steps:
|
||||
# - uses: actions/checkout@v2
|
||||
|
||||
# - name: "Install latest devcontainer CLI"
|
||||
# run: npm install -g @devcontainers/cli
|
||||
|
||||
# - name: "Testing '${{ matrix.features }}' scenarios"
|
||||
# run: devcontainer features test -f ${{ matrix.features }} --skip-autogenerated
|
||||
|
||||
|
||||
TEMPORARY:
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
strategy:
|
||||
matrix:
|
||||
features: ${{ fromJSON(needs.detect-changes.outputs.features) }}
|
||||
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@v2
|
||||
|
||||
- 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:
|
||||
needs: [detect-changes]
|
||||
runs-on: ubuntu-latest
|
||||
continue-on-error: true
|
||||
strategy:
|
||||
matrix:
|
||||
features: ${{ fromJSON(needs.detect-changes.outputs.features) }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: "Install latest devcontainer CLI"
|
||||
run: npm install -g @devcontainers/cli
|
||||
|
||||
- name: "Testing '${{ matrix.features }}' scenarios"
|
||||
run: devcontainer features test -f ${{ matrix.features }} --skip-autogenerated .
|
||||
- name: "TEMPORARY: test install_non_root_remoteUser"
|
||||
run: devcontainer features test -f dotnet --skip-autogenerated --filter install_non_root_remoteUser
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"id": "dotnet",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.1",
|
||||
"name": "Dotnet CLI",
|
||||
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/dotnet",
|
||||
"description": "Installs the .NET CLI. Provides option of installing sdk or runtime, and option of versions to install. Uses latest version of .NET sdk as defaults to install.",
|
||||
|
|
|
@ -15,7 +15,7 @@ INSTALL_USING_APT=${INSTALLUSINGAPT:-"true"}
|
|||
DOTNET_LATEST="7"
|
||||
DOTNET_LTS="6"
|
||||
|
||||
USERNAME=${USERNAME:-"automatic"}
|
||||
USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}"
|
||||
UPDATE_RC=${UPDATE_RC:-"true"}
|
||||
TARGET_DOTNET_ROOT=${TARGET_DOTNET_ROOT:-"/usr/local/dotnet"}
|
||||
ACCESS_GROUP=${ACCESS_GROUP:-"dotnet"}
|
||||
|
@ -187,6 +187,8 @@ install_using_apt() {
|
|||
local target_dotnet_version="$2"
|
||||
local use_msft_repo="$3"
|
||||
|
||||
echo "🚀 Starting install_using_apt ('${sdk_or_runtime}' at version '${target_dotnet_version}' from msft repo '${use_msft_repo}')..."
|
||||
|
||||
if [ "${use_msft_repo}" = "true" ]; then
|
||||
# Install dependencies
|
||||
check_packages apt-transport-https curl ca-certificates gnupg2 dirmngr
|
||||
|
@ -316,6 +318,8 @@ install_using_dotnet_releases_url() {
|
|||
local sdk_or_runtime="$1"
|
||||
local version="$2"
|
||||
|
||||
echo "🚀 Starting install_using_dotnet_releases_url (${sdk_or_runtime} version ${version})..."
|
||||
|
||||
# Check listed package dependecies and install them if they are not already installed.
|
||||
# NOTE: icu-devtools is a small package with similar dependecies to .NET.
|
||||
# It will install the appropriate dependencies based on the OS:
|
||||
|
@ -429,6 +433,7 @@ if [[ "${DOTNET_ARCHIVE_ARCHITECTURES}" = *"${architecture}"* ]] && [[ "${DOTNE
|
|||
echo "Could not install requested version from apt on current distribution."
|
||||
exit 1
|
||||
fi
|
||||
CHANGE_OWNERSHIP="true"
|
||||
else
|
||||
if [[ "${INSTALL_USING_APT}" = "false" ]]; then
|
||||
echo "Installing dotnet from releases url"
|
||||
|
@ -452,14 +457,17 @@ if [ ! -z "${ADDITIONAL_VERSIONS}" ]; then
|
|||
fi
|
||||
|
||||
if [ "${CHANGE_OWNERSHIP}" = "true" ]; then
|
||||
echo "Changing ownership ("${USERNAME}" <- "${TARGET_DOTNET_ROOT}")"
|
||||
if ! cat /etc/group | grep -e "^dotnet:" > /dev/null 2>&1; then
|
||||
groupadd -r dotnet
|
||||
fi
|
||||
usermod -a -G dotnet "${USERNAME}"
|
||||
|
||||
chown -R "${USERNAME}:dotnet" "${TARGET_DOTNET_ROOT}"
|
||||
chown -H -R "${USERNAME}:dotnet" "${TARGET_DOTNET_ROOT}" # Recursively traverse (-R), also following symbolic links (-H)
|
||||
chmod -R g+r+w "${TARGET_DOTNET_ROOT}"
|
||||
find "${TARGET_DOTNET_ROOT}" -type d -print0 | xargs -n 1 -0 chmod g+s
|
||||
else
|
||||
echo "Not changing ownership ("${USERNAME}" <- "${TARGET_DOTNET_ROOT}")"
|
||||
fi
|
||||
|
||||
# Clean up
|
||||
|
|
8
test/dotnet/assert_run_project.sh
Normal file
8
test/dotnet/assert_run_project.sh
Normal file
|
@ -0,0 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
source dev-container-features-test-lib
|
||||
|
||||
cd example_project
|
||||
check "dotnet run" bash -c "dotnet run | grep 'Inception'"
|
2
test/dotnet/example_project/.gitignore
vendored
Normal file
2
test/dotnet/example_project/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
bin
|
||||
obj
|
8
test/dotnet/example_project/Movie.cs
Normal file
8
test/dotnet/example_project/Movie.cs
Normal file
|
@ -0,0 +1,8 @@
|
|||
// See https://aka.ms/new-console-template for more information
|
||||
|
||||
internal class Movie
|
||||
{
|
||||
public string Name { get; set; } = "Default Name";
|
||||
public DateTime ReleaseDate { get; set; }
|
||||
public List<string> Genres { get; set; } = new List<string>();
|
||||
}
|
27
test/dotnet/example_project/Program.cs
Normal file
27
test/dotnet/example_project/Program.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
// See https://aka.ms/new-console-template for more information
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
Console.WriteLine("Hello, World!");
|
||||
|
||||
string json = @"{
|
||||
'Name': 'Inception',
|
||||
'ReleaseDate': '2010-07-08T00:00:00',
|
||||
'Genres': [
|
||||
'Action',
|
||||
'Thriller'
|
||||
]
|
||||
}";
|
||||
|
||||
Movie? m = JsonConvert.DeserializeObject<Movie>(json);
|
||||
|
||||
if (m == default)
|
||||
{
|
||||
Console.WriteLine("Decoding failed!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"Name: {m.Name}");
|
||||
Console.WriteLine($"Release Date: {m.ReleaseDate}");
|
||||
Console.WriteLine($"Genres: {string.Join(", ", m.Genres)}");
|
||||
}
|
14
test/dotnet/example_project/example_project.csproj
Normal file
14
test/dotnet/example_project/example_project.csproj
Normal file
|
@ -0,0 +1,14 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
|
@ -13,5 +13,7 @@ check "dotnet version 3.1.420 installed" bash -c "ls -l /usr/local/dotnet | gre
|
|||
check "current link dotnet" /usr/local/dotnet/current/dotnet --info
|
||||
check "current link sdk" ls -l /usr/local/dotnet/current/sdk
|
||||
|
||||
./assert_run_project.sh
|
||||
|
||||
# Report result
|
||||
reportResults
|
||||
|
|
|
@ -13,5 +13,7 @@ check "dotnet version 3 installed" bash -c "ls -l /usr/share/dotnet/sdk | grep
|
|||
check "current link dotnet" /usr/local/dotnet/current/dotnet --info
|
||||
check "current link sdk" ls -l /usr/local/dotnet/current/sdk
|
||||
|
||||
./assert_run_project.sh
|
||||
|
||||
# Report result
|
||||
reportResults
|
||||
|
|
|
@ -13,5 +13,7 @@ check "dotnet version 6 installed" bash -c "ls -l /usr/share/dotnet/sdk | grep
|
|||
check "current link dotnet" /usr/local/dotnet/current/dotnet --info
|
||||
check "current link sdk" ls -l /usr/local/dotnet/current/sdk
|
||||
|
||||
./assert_run_project.sh
|
||||
|
||||
# Report result
|
||||
reportResults
|
||||
|
|
|
@ -13,5 +13,7 @@ check "dotnet version 7 installed" bash -c "ls -l /usr/share/dotnet/sdk | grep
|
|||
check "current link dotnet" /usr/local/dotnet/current/dotnet --info
|
||||
check "current link sdk" ls -l /usr/local/dotnet/current/sdk
|
||||
|
||||
./assert_run_project.sh
|
||||
|
||||
# Report result
|
||||
reportResults
|
||||
|
|
|
@ -13,5 +13,7 @@ check "dotnet version 7 installed" bash -c "ls -l /usr/share/dotnet/sdk | grep
|
|||
check "current link dotnet" /usr/local/dotnet/current/dotnet --info
|
||||
check "current link sdk" ls -l /usr/local/dotnet/current/sdk
|
||||
|
||||
./assert_run_project.sh
|
||||
|
||||
# Report result
|
||||
reportResults
|
||||
|
|
|
@ -13,5 +13,7 @@ check "dotnet version 7 installed" bash -c "ls -l /usr/share/dotnet/sdk | grep
|
|||
check "current link dotnet" /usr/local/dotnet/current/dotnet --info
|
||||
check "current link sdk" ls -l /usr/local/dotnet/current/sdk
|
||||
|
||||
./assert_run_project.sh
|
||||
|
||||
# Report result
|
||||
reportResults
|
||||
|
|
|
@ -13,5 +13,7 @@ check "dotnet version 6 installed" bash -c "ls -l /usr/share/dotnet/sdk | grep
|
|||
check "current link dotnet" /usr/local/dotnet/current/dotnet --info
|
||||
check "current link sdk" ls -l /usr/local/dotnet/current/sdk
|
||||
|
||||
./assert_run_project.sh
|
||||
|
||||
# Report result
|
||||
reportResults
|
||||
|
|
23
test/dotnet/install_non_root_remoteUser.sh
Normal file
23
test/dotnet/install_non_root_remoteUser.sh
Normal file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
# Optional: Import test library
|
||||
source dev-container-features-test-lib
|
||||
|
||||
check "ensure i am user codespace" bash -c "whoami | grep 'codespace'"
|
||||
|
||||
echo "Echoing contents of '/home/codespace/' ...."
|
||||
ls -la /home/codespace/
|
||||
|
||||
echo "Echoing contents of '/home/codespace/.dotnet' ...."
|
||||
ls -la /home/codespace/.dotnet/
|
||||
|
||||
check "symlinked '/home/codespace/.dotnet' folder has the correct permissions" bash -c "ls -la /home/codespace | grep -E 'lrwxrwxrwx 1 codespace codespace (.*) .dotnet -> /usr/local/dotnet/current'"
|
||||
|
||||
# check "A file following the symlink has the correct permissions" bash -c ""
|
||||
|
||||
./install_dotnet_7_jammy.sh
|
||||
|
||||
# Report result
|
||||
reportResults
|
|
@ -13,5 +13,7 @@ check "dotnet version 7 installed" bash -c "ls -l /usr/local/dotnet | grep '7\.
|
|||
check "current link dotnet" /usr/local/dotnet/current/dotnet --info
|
||||
check "current link sdk" ls -l /usr/local/dotnet/current/sdk
|
||||
|
||||
./assert_run_project.sh
|
||||
|
||||
# Report result
|
||||
reportResults
|
||||
|
|
|
@ -72,5 +72,14 @@
|
|||
"installUsingApt": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"install_non_root_remoteUser": {
|
||||
"image": "mcr.microsoft.com/devcontainers/universal:2",
|
||||
"remoteUser": "codespace",
|
||||
"features": {
|
||||
"dotnet": {
|
||||
"version": "7"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,5 +17,7 @@ check "some major version of dotnet 7 is installed" bash -c "dotnet --version |
|
|||
check "current link dotnet" /usr/local/dotnet/current/dotnet --info
|
||||
check "current link sdk" ls -l /usr/local/dotnet/current/sdk
|
||||
|
||||
./assert_run_project.sh
|
||||
|
||||
# Report result
|
||||
reportResults
|
Loading…
Reference in a new issue