Skip to content

Develop #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/snyk-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ jobs:
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore algorithm-exercises-csharp.sln
run: dotnet restore algorithm_exercises_csharp.sln
- name: Run Snyk to check for vulnerabilities
continue-on-error: true # To make sure that SARIF upload gets called
run: >
snyk test
algorithm-exercises-csharp/
algorithm-exercises-csharp-base/
algorithm-exercises-csharp-test/
algorithm_exercises_csharp/
algorithm_exercises_csharp_base/
algorithm_exercises_csharp_test/
--sarif-file-output=snyk-code.sarif
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
Expand Down
52 changes: 26 additions & 26 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ ENV WORKDIR=/app
WORKDIR ${WORKDIR}

COPY ./Makefile ${WORKDIR}/
COPY ./algorithm-exercises-csharp.sln ${WORKDIR}/algorithm-exercises-csharp.sln
COPY ./algorithm-exercises-csharp/algorithm-exercises-csharp.csproj ${WORKDIR}/algorithm-exercises-csharp/algorithm-exercises-csharp.csproj
COPY ./algorithm-exercises-csharp-base/algorithm-exercises-csharp-base.csproj ${WORKDIR}/algorithm-exercises-csharp-base/algorithm-exercises-csharp-base.csproj
COPY ./algorithm-exercises-csharp-test/algorithm-exercises-csharp-test.csproj ${WORKDIR}/algorithm-exercises-csharp-test/algorithm-exercises-csharp-test.csproj
COPY ./algorithm_exercises_csharp.sln ${WORKDIR}/algorithm_exercises_csharp.sln
COPY ./algorithm_exercises_csharp/algorithm_exercises_csharp.csproj ${WORKDIR}/algorithm_exercises_csharp/algorithm_exercises_csharp.csproj
COPY ./algorithm_exercises_csharp_base/algorithm_exercises_csharp_base.csproj ${WORKDIR}/algorithm_exercises_csharp_base/algorithm_exercises_csharp_base.csproj
COPY ./algorithm_exercises_csharp_test/algorithm_exercises_csharp_test.csproj ${WORKDIR}/algorithm_exercises_csharp_test/algorithm_exercises_csharp_test.csproj

RUN make dependencies

Expand All @@ -26,10 +26,9 @@ FROM base AS lint
ENV WORKDIR=/app
WORKDIR ${WORKDIR}

RUN apk add --update --no-cache make nodejs npm
RUN apk add --update --no-cache yamllint

RUN npm install -g --ignore-scripts markdownlint-cli
RUN apk add --update --no-cache make nodejs npm \
&& apk add --update --no-cache yamllint \
&& npm install -g --ignore-scripts markdownlint-cli

# [!TIP] Use a bind-mount to "/app" to override following "copys"
# for lint and test against "current" sources in this stage
Expand All @@ -45,10 +44,10 @@ COPY ./LICENSE.md ${WORKDIR}/
COPY ./CODE_OF_CONDUCT.md ${WORKDIR}/

# Code source
COPY ./algorithm-exercises-csharp ${WORKDIR}/algorithm-exercises-csharp
COPY ./algorithm-exercises-csharp-base ${WORKDIR}/algorithm-exercises-csharp-base
COPY ./algorithm-exercises-csharp-test ${WORKDIR}/algorithm-exercises-csharp-test
COPY ./algorithm-exercises-csharp.sln ${WORKDIR}/algorithm-exercises-csharp.sln
COPY ./algorithm_exercises_csharp.sln ${WORKDIR}/algorithm_exercises_csharp.sln
COPY ./algorithm_exercises_csharp ${WORKDIR}/algorithm_exercises_csharp
COPY ./algorithm_exercises_csharp_base ${WORKDIR}/algorithm_exercises_csharp_base
COPY ./algorithm_exercises_csharp_test ${WORKDIR}/algorithm_exercises_csharp_test

# code linting conf
COPY ./.editorconfig ${WORKDIR}/
Expand All @@ -65,20 +64,20 @@ CMD ["make", "lint"]
###############################################################################
FROM base AS development

COPY ./algorithm-exercises-csharp ${WORKDIR}/algorithm-exercises-csharp
COPY ./algorithm-exercises-csharp-base ${WORKDIR}/algorithm-exercises-csharp-base
COPY ./algorithm-exercises-csharp-test ${WORKDIR}/algorithm-exercises-csharp-test
COPY ./algorithm-exercises-csharp.sln ${WORKDIR}/algorithm-exercises-csharp.sln
COPY ./algorithm_exercises_csharp.sln ${WORKDIR}/algorithm_exercises_csharp.sln
COPY ./algorithm_exercises_csharp ${WORKDIR}/algorithm_exercises_csharp
COPY ./algorithm_exercises_csharp_base ${WORKDIR}/algorithm_exercises_csharp_base
COPY ./algorithm_exercises_csharp_test ${WORKDIR}/algorithm_exercises_csharp_test

RUN make build
RUN ls -alh
RUN make build \
&& ls -alh

# CMD []
###############################################################################
FROM development AS builder

RUN dotnet publish --self-contained --runtime linux-musl-x64
RUN ls -alh
RUN dotnet publish --self-contained --runtime linux-musl-x64 \
&& ls -alh

CMD ["ls", "-alh"]

Expand Down Expand Up @@ -106,19 +105,20 @@ CMD ["make", "test"]
##
FROM mcr.microsoft.com/dotnet/runtime:8.0.8-alpine3.19-amd64 AS production

RUN apk add --update --no-cache make

ENV LOG_LEVEL=info
ENV BRUTEFORCE=false
ENV WORKDIR=/app
WORKDIR ${WORKDIR}

RUN adduser -D worker
RUN mkdir -p /app
RUN chown worker:worker /app
RUN adduser -D worker \
&& mkdir -p /app \
&& chown worker:worker /app

RUN apk add --update --no-cache make
COPY ./Makefile ${WORKDIR}/
COPY --from=builder /app/algorithm-exercises-csharp/bin/Release/net8.0/algorithm-exercises-csharp.dll ${WORKDIR}/
COPY --from=builder /app/algorithm-exercises-csharp/bin/Release/net8.0/algorithm-exercises-csharp.runtimeconfig.json ${WORKDIR}/
COPY --from=builder /app/algorithm_exercises_csharp/bin/Release/net8.0/algorithm_exercises_csharp.dll ${WORKDIR}/
COPY --from=builder /app/algorithm_exercises_csharp/bin/Release/net8.0/algorithm_exercises_csharp.runtimeconfig.json ${WORKDIR}/

RUN ls -alh

Expand Down
36 changes: 18 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ RUNTIME_TOOL=dotnet
PACKAGE_TOOL=dotnet
VERBOSITY_LEVEL=normal

PROJECT_DIRECTORY=algorithm-exercises-csharp
BASE_PROJECT_DIRECTORY=algorithm-exercises-csharp-base
TEST_PROJECT_DIRECTORY=algorithm-exercises-csharp-test
MAIN_PROJECT_DIRECTORY=algorithm_exercises_csharp
BASE_PROJECT_DIRECTORY=algorithm_exercises_csharp_base
TEST_PROJECT_DIRECTORY=algorithm_exercises_csharp_test

help: list
@echo ""
Expand Down Expand Up @@ -114,9 +114,9 @@ clean:

rm -vfr .mono/ || true
rm -vfr coverage-report/ || true
find ${PROJECT_DIRECTORY} -path "*/TestResults/*" -type d -print -exec rm -vfr {} ';' || true
find ${PROJECT_DIRECTORY} -path "*/bin/*" -print -exec rm -vfr {} ';' || true
find ${PROJECT_DIRECTORY} -path "*/obj/*" -print -exec rm -vfr {} ';' || true
find ${MAIN_PROJECT_DIRECTORY} -path "*/TestResults/*" -type d -print -exec rm -vfr {} ';' || true
find ${MAIN_PROJECT_DIRECTORY} -path "*/bin/*" -print -exec rm -vfr {} ';' || true
find ${MAIN_PROJECT_DIRECTORY} -path "*/obj/*" -print -exec rm -vfr {} ';' || true

find ${BASE_PROJECT_DIRECTORY} -path "*/TestResults/*" -type d -print -exec rm -vfr {} ';' || true
find ${BASE_PROJECT_DIRECTORY} -path "*/bin/*" -print -exec rm -vfr {} ';' || true
Expand All @@ -128,34 +128,34 @@ clean:
find ${TEST_PROJECT_DIRECTORY} -path "*/obj/*" -print -exec rm -vfr {} ';' || true

compose/build: env
docker-compose --profile lint build
docker-compose --profile testing build
docker-compose --profile production build
${DOCKER_COMPOSE} --profile lint build
${DOCKER_COMPOSE} --profile testing build
${DOCKER_COMPOSE} --profile production build

compose/rebuild: env
docker-compose --profile lint build --no-cache
docker-compose --profile testing build --no-cache
docker-compose --profile production build --no-cache
${DOCKER_COMPOSE} --profile lint build --no-cache
${DOCKER_COMPOSE} --profile testing build --no-cache
${DOCKER_COMPOSE} --profile production build --no-cache

compose/lint/markdown: compose/build
docker-compose --profile lint run --rm algorithm-exercises-csharp-lint make lint/markdown
${DOCKER_COMPOSE} --profile lint run --rm algorithm-exercises-csharp-lint make lint/markdown

compose/lint/yaml: compose/build
docker-compose --profile lint run --rm algorithm-exercises-csharp-lint make lint/yaml
${DOCKER_COMPOSE} --profile lint run --rm algorithm-exercises-csharp-lint make lint/yaml

compose/test/styling: compose/build
docker-compose --profile lint run --rm algorithm-exercises-csharp-lint make test/styling
${DOCKER_COMPOSE} --profile lint run --rm algorithm-exercises-csharp-lint make test/styling

compose/test/static: compose/build
docker-compose --profile lint run --rm algorithm-exercises-csharp-lint make test/static
${DOCKER_COMPOSE} --profile lint run --rm algorithm-exercises-csharp-lint make test/static

compose/lint: compose/lint/markdown compose/lint/yaml compose/test/styling compose/test/static

compose/test: compose/build
docker-compose --profile testing run --rm algorithm-exercises-csharp-test make test
${DOCKER_COMPOSE} --profile testing run --rm algorithm-exercises-csharp-test make test

compose/run: compose/build
docker-compose --profile production run --rm algorithm-exercises-csharp make run
${DOCKER_COMPOSE} --profile production run --rm algorithm-exercises-csharp make run

all: lint coverage

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "algorithm-exercises-csharp-test", "algorithm-exercises-csharp-test\algorithm-exercises-csharp-test.csproj", "{817BA968-9A1F-4DDB-8A96-657DCA862227}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "algorithm_exercises_csharp_test", "algorithm_exercises_csharp_test\algorithm_exercises_csharp_test.csproj", "{817BA968-9A1F-4DDB-8A96-657DCA862227}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "algorithm-exercises-csharp", "algorithm-exercises-csharp\algorithm-exercises-csharp.csproj", "{B162EE62-90C6-4871-B278-390804615987}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "algorithm_exercises_csharp", "algorithm_exercises_csharp\algorithm_exercises_csharp.csproj", "{B162EE62-90C6-4871-B278-390804615987}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "algorithm-exercises-csharp-base", "algorithm-exercises-csharp-base\algorithm-exercises-csharp-base.csproj", "{1BC65C42-83A6-486D-84DB-0DC63002FA24}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "algorithm_exercises_csharp_base", "algorithm_exercises_csharp_base\algorithm_exercises_csharp_base.csproj", "{1BC65C42-83A6-486D-84DB-0DC63002FA24}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="../algorithm-exercises-csharp-base/algorithm-exercises-csharp-base.csproj" />
<ProjectReference Include="../algorithm_exercises_csharp_base/algorithm_exercises_csharp_base.csproj" />
</ItemGroup>
</Project>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
<PackageReference Include="MSTest.TestAdapter" Version="3.5.2" />
<PackageReference Include="MSTest.TestFramework" Version="3.5.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="ReportGenerator" Version="5.3.8" />
</ItemGroup>

Expand All @@ -45,7 +46,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../algorithm-exercises-csharp/algorithm-exercises-csharp.csproj" />
<ProjectReference Include="../algorithm_exercises_csharp/algorithm_exercises_csharp.csproj" />
</ItemGroup>

<Target Name="GenerateHtmlCoverageReport" AfterTargets="GenerateCoverageResultAfterTest">
Expand Down