Skip to content
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

'cache prepare' command #67

Merged
merged 39 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0b71031
test: add Aruba Cucumber testing
CodeMouse92 May 5, 2022
dd648b1
build: update to .NET 6.0
CodeMouse92 May 5, 2022
e93d0a7
test: silence cucumber message sharing results
CodeMouse92 May 5, 2022
d254334
test: Add Aruba to GitHub Actions
CodeMouse92 May 5, 2022
2361362
Committing auto generated change log.
mscottford May 5, 2022
6b8ef5a
refactor: move --output and --format to scan only
CodeMouse92 May 11, 2022
ba6b96d
fix Send_Args_ReturnsScanOptions test
mfcorgi May 12, 2022
395dda7
feat: add 'cache' and 'cache prepare' commands
CodeMouse92 May 12, 2022
665542a
feat: add global --cache-dir option
CodeMouse92 May 12, 2022
e6bdbaf
bug: return code from ScanCommand.Run()
CodeMouse92 May 16, 2022
c2a0637
feat: implement 'cache prepare' command
CodeMouse92 May 16, 2022
7e390a0
refactor test: make VerifyAlias test helper function generic
CodeMouse92 May 17, 2022
3b2acfe
test: --cache-dir global option
CodeMouse92 May 17, 2022
ec85307
test: main command should not itself have a handler
CodeMouse92 May 17, 2022
673b2cc
test: 'cache' and 'cache prepare' commands
CodeMouse92 May 17, 2022
2bbdc4f
test: simplify help test
CodeMouse92 May 17, 2022
a5e2f93
test: testing 'cache prepare' produces valid database
CodeMouse92 May 17, 2022
0cef7b2
Adds migrations folder to ignore list
mscottford May 17, 2022
3def57e
docs: update CONTRIBUTING.md to reflect new architecture
CodeMouse92 May 17, 2022
c30c59e
docs: fix various typos and formatting issues
CodeMouse92 May 17, 2022
53bfbe4
build: track Gemfile.lock again
CodeMouse92 May 18, 2022
cd3f9e9
Adds help for working with the devcontainer
mscottford May 17, 2022
41634c8
Increments SDK version
mscottford May 17, 2022
ea0f906
Refreshes devcontainer
mscottford May 17, 2022
937af35
Reduces duplication within option/argument helper methods
mscottford May 18, 2022
dd8ffdd
Removes unused using statements
mscottford May 18, 2022
3319499
Normalizes file
mscottford May 18, 2022
287ea21
Reduces duplication between test methods
mscottford May 18, 2022
7477441
fix: eliminate use of environment variable for --cache-dir
CodeMouse92 May 18, 2022
5090d35
Merge branch 'main' into cache_prepare
CodeMouse92 May 18, 2022
07de1d8
style: split classes out into dedicated files
CodeMouse92 May 18, 2022
484dc87
Adds coverlet dotnet tool
mscottford May 18, 2022
b9485cf
Ignores addition code coverage report files
mscottford May 18, 2022
c09b05c
Attempts to add code coverage collection for Aruba
mscottford May 18, 2022
071f6c2
Removes extraneous configuration
mscottford May 18, 2022
9f1d82e
Bumps ruby version in CI to match the version in the DevContainer
mscottford May 18, 2022
e626d46
Fixes type "coverlett" -> "coverlet"
mscottford May 18, 2022
849617b
Uses bundler to invoke cucumber executable
mscottford May 18, 2022
2d294b3
Adds docs for collecting coverage data
mscottford May 18, 2022
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
3 changes: 2 additions & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
exclude_patterns:
- "Corgibytes.Freshli.Cli/obj/**"
- "Corgibytes.Freshli.Cli.Test/obj/**"
- "Corgibytes.Freshli.Cli.Test/obj/**"
- "Corgibytes.Freshli.Cli/Migrations/**"
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"coverlet.console": {
"version": "3.1.2",
"commands": [
"coverlet"
]
}
}
}
206 changes: 192 additions & 14 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,201 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.155.1/containers/dotnet/.devcontainer/base.Dockerfile
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.234.0/containers/dotnet/.devcontainer/base.Dockerfile

# [Choice] .NET version: 5.0, 3.1, 2.1
ARG VARIANT="5.0"
FROM mcr.microsoft.com/vscode/devcontainers/dotnetcore:0-${VARIANT}
# [Choice] .NET version: 6.0, 5.0, 3.1, 6.0-bullseye, 5.0-bullseye, 3.1-bullseye, 6.0-focal, 5.0-focal, 3.1-focal
ARG VARIANT="6.0-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/dotnet:0-${VARIANT}

# [Option] Install Node.js
ARG INSTALL_NODE="true"
ARG NODE_VERSION="lts/*"
RUN if [ "${INSTALL_NODE}" = "true" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi

# [Option] Install Azure CLI
ARG INSTALL_AZURE_CLI="false"
COPY library-scripts/azcli-debian.sh /tmp/library-scripts/
RUN if [ "$INSTALL_AZURE_CLI" = "true" ]; then bash /tmp/library-scripts/azcli-debian.sh; fi \
&& apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
# Start buildpack-curl installation
# Copied from https://github.com/docker-library/buildpack-deps/blob/a017681ea2f5891786bfa151a0d38fbea051d4ba/debian/bullseye/curl/Dockerfile
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
netbase \
wget \
; \
rm -rf /var/lib/apt/lists/*

RUN set -ex; \
if ! command -v gpg > /dev/null; then \
apt-get update; \
apt-get install -y --no-install-recommends \
gnupg \
dirmngr \
; \
rm -rf /var/lib/apt/lists/*; \
fi

# Start buildpack-scm installation
# Copied from https://github.com/docker-library/buildpack-deps/blob/a017681ea2f5891786bfa151a0d38fbea051d4ba/debian/bullseye/scm/Dockerfile
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
mercurial \
openssh-client \
subversion \
\
procps \
&& rm -rf /var/lib/apt/lists/*

# Start buildpack installation
# Copied from https://github.com/docker-library/buildpack-deps/blob/a017681ea2f5891786bfa151a0d38fbea051d4ba/debian/bullseye/Dockerfile
RUN set -ex; \
apt-get update; \
apt-get install -y --no-install-recommends \
autoconf \
automake \
bzip2 \
dpkg-dev \
file \
g++ \
gcc \
imagemagick \
libbz2-dev \
libc6-dev \
libcurl4-openssl-dev \
libdb-dev \
libevent-dev \
libffi-dev \
libgdbm-dev \
libglib2.0-dev \
libgmp-dev \
libjpeg-dev \
libkrb5-dev \
liblzma-dev \
libmagickcore-dev \
libmagickwand-dev \
libmaxminddb-dev \
libncurses5-dev \
libncursesw5-dev \
libpng-dev \
libpq-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
libtool \
libwebp-dev \
libxml2-dev \
libxslt-dev \
libyaml-dev \
make \
patch \
unzip \
xz-utils \
zlib1g-dev \
\
# https://lists.debian.org/debian-devel-announce/2016/09/msg00000.html
$( \
# if we use just "apt-cache show" here, it returns zero because "Can't select versions from package 'libmysqlclient-dev' as it is purely virtual", hence the pipe to grep
if apt-cache show 'default-libmysqlclient-dev' 2>/dev/null | grep -q '^Version:'; then \
echo 'default-libmysqlclient-dev'; \
else \
echo 'libmysqlclient-dev'; \
fi \
) \
; \
rm -rf /var/lib/apt/lists/*



# Start Ruby installation
# Copied from https://github.com/docker-library/ruby/blob/ac24ae0a894606d3ac91c28095db39e69771cac4/3.1/bullseye/Dockerfile

# skip installing gem documentation
RUN set -eux; \
mkdir -p /usr/local/etc; \
{ \
echo 'install: --no-document'; \
echo 'update: --no-document'; \
} >> /usr/local/etc/gemrc

ENV LANG C.UTF-8
ENV RUBY_MAJOR 3.1
ENV RUBY_VERSION 3.1.2
ENV RUBY_DOWNLOAD_SHA256 ca10d017f8a1b6d247556622c841fc56b90c03b1803f87198da1e4fd3ec3bf2a

# some of ruby's build scripts are written in ruby
# we purge system ruby later to make sure our final image uses what we just built
RUN set -eux; \
\
savedAptMark="$(apt-mark showmanual)"; \
apt-get update; \
apt-get install -y --no-install-recommends \
bison \
dpkg-dev \
libgdbm-dev \
ruby \
; \
rm -rf /var/lib/apt/lists/*; \
\
wget -O ruby.tar.xz "https://cache.ruby-lang.org/pub/ruby/${RUBY_MAJOR%-rc}/ruby-$RUBY_VERSION.tar.xz"; \
echo "$RUBY_DOWNLOAD_SHA256 *ruby.tar.xz" | sha256sum --check --strict; \
\
mkdir -p /usr/src/ruby; \
tar -xJf ruby.tar.xz -C /usr/src/ruby --strip-components=1; \
rm ruby.tar.xz; \
\
cd /usr/src/ruby; \
\
# hack in "ENABLE_PATH_CHECK" disabling to suppress:
# warning: Insecure world writable dir
{ \
echo '#define ENABLE_PATH_CHECK 0'; \
echo; \
cat file.c; \
} > file.c.new; \
mv file.c.new file.c; \
\
autoconf; \
gnuArch="$(dpkg-architecture --query DEB_BUILD_GNU_TYPE)"; \
./configure \
--build="$gnuArch" \
--disable-install-doc \
--enable-shared \
; \
make -j "$(nproc)"; \
make install; \
\
apt-mark auto '.*' > /dev/null; \
apt-mark manual $savedAptMark > /dev/null; \
find /usr/local -type f -executable -not \( -name '*tkinter*' \) -exec ldd '{}' ';' \
| awk '/=>/ { print $(NF-1) }' \
| sort -u \
| grep -vE '^/usr/local/lib/' \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
| sort -u \
| xargs -r apt-mark manual \
; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
\
cd /; \
rm -r /usr/src/ruby; \
# verify we have no "ruby" packages installed
if dpkg -l | grep -i ruby; then exit 1; fi; \
[ "$(command -v ruby)" = '/usr/local/bin/ruby' ]; \
# rough smoke test
ruby --version; \
gem --version; \
bundle --version

# don't create ".bundle" in all our apps
ENV GEM_HOME /usr/local/bundle
ENV BUNDLE_SILENCE_ROOT_WARNING=1 \
BUNDLE_APP_CONFIG="$GEM_HOME"
ENV PATH $GEM_HOME/bin:$PATH
# adjust permissions of a few directories for running "gem install" as an arbitrary user
RUN mkdir -p "$GEM_HOME" && chmod 777 "$GEM_HOME"

# Install Aruba/Cucumber based acceptance testing tools
RUN gem install bundler

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
29 changes: 12 additions & 17 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.155.1/containers/dotnet
// https://github.com/microsoft/vscode-dev-containers/tree/v0.234.0/containers/dotnet
{
"name": "C# (.NET)",
"build": {
"dockerfile": "Dockerfile",
"args": {
// Update 'VARIANT' to pick a .NET Core version: 2.1, 3.1, 5.0
"VARIANT": "5.0",
// Update 'VARIANT' to pick a .NET Core version: 3.1, 5.0, 6.0
// Append -bullseye or -focal to pin to an OS version.
"VARIANT": "6.0-bullseye",
// Options
"INSTALL_NODE": "false",
"NODE_VERSION": "lts/*",
"INSTALL_AZURE_CLI": "false"
"NODE_VERSION": "lts/*"
}
},

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"dotnet-test-explorer.testArguments": "/p:CollectCoverage=true /p:CoverletOutputFormat=lcov",
"coverage-gutters.coverageFileNames": ["coverage.info"],
},
"settings": {},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-dotnettools.csharp",
"formulahendry.dotnet-test-explorer",
"ryanluker.vscode-coverage-gutters"
"ms-dotnettools.csharp"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
Expand Down Expand Up @@ -55,8 +48,10 @@
// "mounts": [ "source=${env:HOME}${env:USERPROFILE}/.aspnet/https,target=/home/vscode/.aspnet/https,type=bind" ],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "dotnet restore",
"postCreateCommand": "bundle install && dotnet restore",

// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"features": {
}
}
33 changes: 0 additions & 33 deletions .devcontainer/library-scripts/azcli-debian.sh

This file was deleted.

35 changes: 21 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,30 +100,37 @@ jobs:
echo "NUGET_PACKAGE_PATH=${{ env.BUILD_ARTIFACTS_FOLDER }}/Corgibytes.Freshli.Cli.${{ steps.gitversion.outputs.NuGetVersionV2 }}.nupkg" >> $GITHUB_ENV

- name: "[Test] - Test, Generate Code Coverage"
if: ${{ !env.ACT }}
uses: paambaati/codeclimate-action@v2.7.5
env:
CC_TEST_REPORTER_ID: ${{ secrets.TEST_REPORTER_ID }}
with:
coverageCommand: dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=lcov
coverageLocations: |
${{github.workspace}}/Corgibytes.Freshli.Cli.Test/coverage.info:lcov
run: |
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=lcov

- name: "[Test] - Setup for Behavior Acceptance Tests"
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6 # Not needed with a .ruby-version file
ruby-version: 3.1 # Not needed with a .ruby-version file
bundler-cache: true

- name: "[Test] - Behavior Acceptance Tests"
- name: "[Test] - Setup for Acceptance Test Coverage Collection"
run: |
dotnet tool restore

- name: "[Test] - Behavior Acceptance Tests with Coverage Collection"
run: |
dotnet build -o bin && bundle exec cucumber
dotnet build -o bin && dotnet coverlet ./bin --target "bundle" --targetargs "exec cucumber" --output ./coverage-acceptance.info --format lcov

- name: "[Test] - Send Code Coverage Data to Code Climate"
uses: paambaati/codeclimate-action@v3.0.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.TEST_REPORTER_ID }}
with:
coverageLocations: |
${{github.workspace}}/Corgibytes.Freshli.Cli.Test/coverage.info
${{github.workspace}}/coverage-acceptance.info

- name: "[Publish] - Publish win-x64, linux-x64 and osx-x64"
run: |
dotnet publish -r win-x64 -c Release --self-contained false
dotnet publish -r linux-x64 -c Release --self-contained false
dotnet publish -r osx-x64 -c Release --self-contained false
dotnet publish -r win-x64 -c Release --self-contained false
dotnet publish -r linux-x64 -c Release --self-contained false
dotnet publish -r osx-x64 -c Release --self-contained false

- name: "[Post Publish] - Zip win-x64 Release"
uses: papeloto/action-zip@v1
Expand Down
Loading