Compare commits

...

5 commits

Author SHA1 Message Date
Josh Spicer
eaa0aff422
more change 2022-11-18 00:27:29 +00:00
Josh Spicer
18db2f09c7
attempt to debug why this is not working in Action 2022-11-18 00:25:06 +00:00
Josh Spicer
883c99bc1e
remove un-needed whitespace 2022-11-17 00:40:07 +00:00
Josh Spicer
dadaffc450
1.1.0 -> 1.1.1 2022-11-16 22:26:16 +00:00
Josh Spicer
348ee69aaa
follow symlinks when chowning and add practical dotnet test 2022-11-16 22:18:29 +00:00
19 changed files with 202 additions and 72 deletions

View file

@ -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

View file

@ -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.",

View file

@ -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

View 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'"

View file

@ -0,0 +1,2 @@
bin
obj

View 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>();
}

View 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)}");
}

View 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>

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View 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

View file

@ -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

View file

@ -72,5 +72,14 @@
"installUsingApt": false
}
}
},
"install_non_root_remoteUser": {
"image": "mcr.microsoft.com/devcontainers/universal:2",
"remoteUser": "codespace",
"features": {
"dotnet": {
"version": "7"
}
}
}
}

View file

@ -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