From fa60292ccf31bd1ea2078815f5d2efa547470f15 Mon Sep 17 00:00:00 2001 From: Gonzalo Diaz Date: Wed, 12 Jun 2024 21:16:50 -0400 Subject: [PATCH 1/2] [CONFIG] License file renamed as Markdown. Code of conduct file added. --- CODE_OF_CONDUCT.md | 128 ++++++++++++++++++++++++++++++++++++++++++ LICENSE => LICENSE.md | 2 +- 2 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 CODE_OF_CONDUCT.md rename LICENSE => LICENSE.md (98%) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..71c8c3a --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,128 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, religion, or sexual identity +and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the + overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or + advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email + address, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +. +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series +of actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or +permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within +the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.0, available at +. + +Community Impact Guidelines were inspired by [Mozilla's code of conduct +enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at +. Translations are available at +. diff --git a/LICENSE b/LICENSE.md similarity index 98% rename from LICENSE rename to LICENSE.md index 86e7d05..782288c 100644 --- a/LICENSE +++ b/LICENSE.md @@ -1,4 +1,4 @@ -MIT License +# MIT License Copyright (c) 2022 Gonzalo Diaz From 91c8d850b5a7c57f06e1222de7804f2e9f1f3051 Mon Sep 17 00:00:00 2001 From: Gonzalo Diaz Date: Wed, 12 Jun 2024 22:35:51 -0400 Subject: [PATCH 2/2] [CONFIG] [Docker] building process re-organized. [StackOverflow] A fatal error was encountered. The library 'libhostpolicy.so' required: https://stackoverflow.com/a/59185091/6366150 --- Dockerfile | 69 +++++++++++++++---- Makefile | 15 +++- .../algorithm-exercises-csharp.csproj | 2 + compose.yaml | 21 ++++-- 4 files changed, 86 insertions(+), 21 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0fa0804..311dfb3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,68 +4,107 @@ FROM mcr.microsoft.com/dotnet/sdk:8.0.302-alpine3.19-amd64 AS base ENV WORKDIR=/app WORKDIR ${WORKDIR} +RUN apk add --update --no-cache make + ############################################################################### FROM base AS lint ENV WORKDIR=/app WORKDIR ${WORKDIR} -COPY ./docs ${WORKDIR}/docs RUN apk add --update --no-cache make nodejs npm RUN apk add --update --no-cache yamllint RUN npm install -g --ignore-scripts markdownlint-cli -############################################################################### -FROM base AS development +# [!TIP] Use a bind-mount to "/app" to override following "copys" +# for lint and test against "current" sources in this stage -RUN apk add --update --no-cache make +# YAML sources +COPY ./.github ${WORKDIR}/ +COPY ./compose.yaml ${WORKDIR}/ + +# Markdown sources +COPY ./docs ${WORKDIR}/ +COPY ./README.md ${WORKDIR}/ +COPY ./LICENSE.md ${WORKDIR}/ +COPY ./CODE_OF_CONDUCT.md ${WORKDIR}/ + +# Code source +COPY ./algorithm-exercises-csharp ${WORKDIR}/algorithm-exercises-csharp +COPY ./algorithm-exercises-csharp-test ${WORKDIR}/algorithm-exercises-csharp-test +COPY ./algorithm-exercises-csharp.sln ${WORKDIR}/algorithm-exercises-csharp.sln +COPY ./Makefile ${WORKDIR}/ + +# code linting conf +COPY ./.editorconfig ${WORKDIR}/ + +# markdownlint conf +COPY ./.markdownlint.yaml ${WORKDIR}/ + +# yamllint conf +COPY ./.yamllint ${WORKDIR}/ +COPY ./.yamlignore ${WORKDIR}/ ############################################################################### -FROM development AS builder +FROM base AS development COPY ./algorithm-exercises-csharp ${WORKDIR}/algorithm-exercises-csharp +COPY ./algorithm-exercises-csharp-test ${WORKDIR}/algorithm-exercises-csharp-test COPY ./algorithm-exercises-csharp.sln ${WORKDIR}/algorithm-exercises-csharp.sln COPY ./Makefile ${WORKDIR}/ + +RUN make build +RUN ls -alh + +# CMD [] +############################################################################### +FROM development AS builder + +RUN dotnet publish --self-contained --runtime linux-musl-x64 RUN ls -alh +CMD ["ls", "-alh"] + ############################################################################### ### In testing stage, can't use USER, due permissions issue ## in github actions environment: ## ## https://docs.github.com/en/actions/creating-actions/dockerfile-support-for-github-actions ## -FROM builder AS testing +FROM development AS testing ENV LOG_LEVEL=INFO ENV BRUTEFORCE=false WORKDIR /app -COPY ./algorithm-exercises-csharp-test ${WORKDIR}/algorithm-exercises-csharp-test RUN ls -alh -CMD ["dotnet", "test"] +CMD ["make", "test"] ############################################################################### ### In production stage ## in the production phase, "good practices" such as -## WORKSPACE and USER are maintained +## WORKDIR and USER are maintained ## -FROM builder AS production +FROM mcr.microsoft.com/dotnet/runtime:8.0.3-alpine3.19-amd64 AS production -ENV LOG_LEVEL=INFO +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 -WORKDIR /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 ./.pylintrc ${WORKDIR}/ -COPY ./.coveragerc ${WORKDIR}/ RUN ls -alh USER worker -CMD ["make", "test", "-e", "{DEBUG}"] +CMD ["make", "run"] diff --git a/Makefile b/Makefile index 1997cc0..5f704fa 100644 --- a/Makefile +++ b/Makefile @@ -87,6 +87,9 @@ format: build: env dependencies ${PACKAGE_TOOL} build --verbosity ${VERBOSITY_LEVEL} +release: dependencies + ${PACKAGE_TOOL} publish --verbosity ${VERBOSITY_LEVEL} + test: build ${PACKAGE_TOOL} test --verbosity ${VERBOSITY_LEVEL} --collect:"Code Coverage" @@ -119,10 +122,12 @@ clean: compose/build: env 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 compose/lint/markdown: compose/build docker-compose --profile lint run --rm algorithm-exercises-csharp-lint make lint/markdown @@ -134,11 +139,17 @@ compose/test/styling: compose/build docker-compose --profile lint run --rm algorithm-exercises-csharp-lint make test/styling compose/test/static: compose/build - docker-compose --profile testing run --rm algorithm-exercises-csharp 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 + compose/run: compose/build - docker-compose --profile testing run --rm algorithm-exercises-csharp make test + docker-compose --profile production run --rm algorithm-exercises-csharp make run all: lint coverage + +run: + ls -alh diff --git a/algorithm-exercises-csharp/algorithm-exercises-csharp.csproj b/algorithm-exercises-csharp/algorithm-exercises-csharp.csproj index 6fd909b..fe86a87 100644 --- a/algorithm-exercises-csharp/algorithm-exercises-csharp.csproj +++ b/algorithm-exercises-csharp/algorithm-exercises-csharp.csproj @@ -6,6 +6,8 @@ enable enable + true + true true diff --git a/compose.yaml b/compose.yaml index 796d2a3..76f1ea5 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,7 +1,7 @@ --- services: - algorithm-exercises-csharp: - image: algorithm-exercises-csharp:latest + algorithm-exercises-csharp-test: + image: algorithm-exercises-csharp:test build: context: . target: testing @@ -18,8 +18,8 @@ services: context: . target: lint # environment: - #  LOG_LEVEL: ${LOG_LEVEL:-info} ## (1) ## info | debug - #  BRUTEFORCE: ${BRUTEFORCE:-false} ## (1) ## true | false + # LOG_LEVEL: ${LOG_LEVEL:-info} ## (1) ## info | debug + # BRUTEFORCE: ${BRUTEFORCE:-false} ## (1) ## true | false volumes: - ./:/app profiles: ["lint"] @@ -35,6 +35,19 @@ services: volumes: - ./:/app profiles: ["development"] + + algorithm-exercises-csharp: + image: algorithm-exercises-csharp:latest + build: + context: . + target: production + environment: + LOG_LEVEL: ${LOG_LEVEL:-INFO} + BRUTEFORCE: ${BRUTEFORCE:-false} ## (1) ## true | false + # volumes: + # - ./:/app + profiles: ["production"] + ## REFERENCES: ## (1) Passing Environment variable with fallback value: ## https://stackoverflow.com/a/70772707/6366150