Skip to content

Commit

Permalink
[Add] - Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollo3zehn committed Mar 2, 2024
0 parents commit e1e25e3
Show file tree
Hide file tree
Showing 269 changed files with 41,363 additions and 0 deletions.
37 changes: 37 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# How to format:
# (1) Add dotnet_diagnostic.XXXX.severity = error
# (2) Run dotnet-format: dotnet format --diagnostics XXXX

[*.cs]
# "run cleanup": https://betterprogramming.pub/enforce-net-code-style-with-editorconfig-d2f0d79091ac
# TODO: build real editorconfig file: https://github.com/dotnet/roslyn/blob/main/.editorconfig

# Enable naming rule violation errors on build (alternative: dotnet_analyzer_diagnostic.category-Style.severity = error)
dotnet_diagnostic.IDE1006.severity = error

#########################
# example: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/style-rules/naming-rules#example-private-instance-fields-with-underscore
#########################

# Define the 'private_fields' symbol group:
dotnet_naming_symbols.private_fields.applicable_kinds = field
dotnet_naming_symbols.private_fields.applicable_accessibilities = private

# Define the 'private_static_fields' symbol group
dotnet_naming_symbols.private_static_fields.applicable_kinds = field
dotnet_naming_symbols.private_static_fields.applicable_accessibilities = private
dotnet_naming_symbols.private_static_fields.required_modifiers = static

# Define the 'underscored' naming style
dotnet_naming_style.underscored.capitalization = camel_case
dotnet_naming_style.underscored.required_prefix = _

# Define the 'private_fields_underscored' naming rule
dotnet_naming_rule.private_fields_underscored.symbols = private_fields
dotnet_naming_rule.private_fields_underscored.style = underscored
dotnet_naming_rule.private_fields_underscored.severity = error

# Define the 'private_static_fields_none' naming rule
dotnet_naming_rule.private_static_fields_none.symbols = private_static_fields
dotnet_naming_rule.private_static_fields_none.style = underscored
dotnet_naming_rule.private_static_fields_none.severity = none
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sh text eol=lf
200 changes: 200 additions & 0 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
name: Build and Publish

on:
push:
branches:
- master
- dev

tags:
- '*'

jobs:

build:

name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Fetch tags
run: git fetch --tags --force

- name: Metadata
run: echo "IS_RELEASE=${{ startsWith(github.ref, 'refs/tags/') }}" >> $GITHUB_ENV

- name: Environment
run: |
echo "VERSION=$(python build/print_version.py ${{ github.run_number }} ${{ env.IS_RELEASE }} false)" >> $GITHUB_ENV
echo "PYPI_VERSION=$(python build/print_version.py ${{ github.run_number }} ${{ env.IS_RELEASE }} pypi)" >> $GITHUB_ENV
echo "$(python build/print_solution.py)" >> $GITHUB_ENV
- name: Extract annotation tag
if: ${{ env.IS_RELEASE == 'true' }}
run: python build/create_tag_body.py

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.9'

- name: Create Docker Output Folder
run: mkdir --parent artifacts/images

- name: Install
run: |
npm install -g pyright
python -m pip install frictionless==4.40.9 build wheel httpx pytest pytest-asyncio
npm install -g [email protected]
dotnet tool install -g Microsoft.Web.LibraryManager.Cli
dotnet workload install --temp-dir tmp wasm-tools
- name: Docker Setup
id: buildx
uses: docker/setup-buildx-action@v1

- name: Build
run: |
(cd src/Nexus.UI && libman restore)
dotnet publish -c Release -o app /p:GeneratePackage=true src/Nexus/Nexus.csproj
python -m build --wheel --outdir artifacts/packages --no-isolation src/clients/python-client
python -m build --wheel --outdir artifacts/packages --no-isolation src/extensibility/python-extensibility
- name: Test
run: |
dotnet test -c Release /p:BuildProjectReferences=false
pyright
pytest
- name: Docker Build
run: |
docker build -t malstroem-labs/nexus:v_next .
docker save --output artifacts/images/nexus_image.tar malstroem-labs/nexus:v_next
- name: CSS
run: |
npx tailwindcss -i src/Nexus/Styles/app.css -o app_new.css
diff src/Nexus/wwwroot/css/app.css app_new.css
- name: API
run: |
dotnet run --project src/Nexus.ClientGenerator/Nexus.ClientGenerator.csproj -- ./ openapi_new.json
diff --strip-trailing-cr openapi.json openapi_new.json
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: artifacts
path: |
artifacts/*.txt
artifacts/packages/
artifacts/images/
- name: Prepare GitHub Pages
run: |
touch app/wwwroot/.nojekyll
sed -i 's/<base href="\/" \/>/<base href="\/nexus\/" \/>/g' app/wwwroot/index.html
if: github.ref == 'refs/heads/master'

- name: Deploy GitHub Pages
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: app/wwwroot
if: github.ref == 'refs/heads/master'

outputs:
is_release: ${{ env.IS_RELEASE }}
version: ${{ env.VERSION }}

publish_dev:

needs: build
name: Publish (dev)
runs-on: ubuntu-latest

if: ${{ needs.build.outputs.is_release != 'true' }}

steps:

- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: artifacts
path: artifacts

- name: Docker Load Image
run: docker load --input artifacts/images/nexus_image.tar

- name: Nuget package (MyGet)
run: dotnet nuget push 'artifacts/packages/*.nupkg' --api-key ${MYGET_API_KEY} --source https://www.myget.org/F/apollo3zehn-dev/api/v3/index.json
env:
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }}

- name: Python package (MyGet)
run: 'for filePath in artifacts/packages/*.whl; do curl -k -X POST https://www.myget.org/F/apollo3zehn-dev/python/upload -H "Authorization: Bearer ${MYGET_API_KEY}" -F "data=@$filePath"; done'
env:
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }}

- name: Docker Login (Github Container Registry)
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker Push
run: |
docker tag malstroem-labs/nexus:v_next ghcr.io/malstroem-labs/nexus:${{ needs.build.outputs.version }}
docker push ghcr.io/malstroem-labs/nexus:${{ needs.build.outputs.version }}
publish_release:

needs: build
name: Publish (release)
runs-on: ubuntu-latest

if: ${{ needs.build.outputs.is_release == 'true' }}

steps:

- name: Install
run: |
python -m pip install twine
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
name: artifacts
path: artifacts

- name: Docker Load Image
run: docker load --input artifacts/images/nexus_image.tar

- name: GitHub Release Artifacts
uses: softprops/action-gh-release@v1
with:
body_path: artifacts/tag_body.txt

- name: Nuget package (Nuget)
run: dotnet nuget push 'artifacts/packages/*.nupkg' --api-key ${NUGET_API_KEY} --source https://api.nuget.org/v3/index.json
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}

- name: Python Package (PyPI)
run: twine upload artifacts/packages/*.whl -u__token__ -p"${PYPI_API_KEY}"
env:
PYPI_API_KEY: ${{ secrets.PYPI_API_KEY }}

- name: Docker Login (Docker Hub)
uses: docker/login-action@v1
with:
username: malstroemlabs
password: ${{ secrets.DOCKER_API_KEY }}

- name: Docker Push
run: |
docker tag malstroem-labs/nexus:v_next malstroemlabs/nexus:${{ needs.build.outputs.version }}
docker push malstroemlabs/nexus:${{ needs.build.outputs.version }}
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.vs/
.venv/
artifacts/
BenchmarkDotNet.Artifacts

doc/_site
/**/obj
**/wwwroot/lib/

doc/api/*

*.suo
*.user
*.pyc
79 changes: 79 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"justMyCode": true
},
{
"name": "Launch Nexus",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/artifacts/bin/Nexus/debug/Nexus.dll",
"args": [],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
{
/* How to debug into remote Nexus Docker container via SSH
* 1. Install SSH on container (docker exec -it <container name> bash)
* - apt update; apt install openssh-server nano curl -y
* - sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
* - service ssh start
* - password=eJW2PJvrngD6gNv3 # for testing purpose only
* - echo -e "$password\n$password" | passwd
* - curl -sSL https://aka.ms/getvsdbgsh | /bin/sh /dev/stdin -v latest -l ~/vsdbg # https://github.com/OmniSharp/omnisharp-vscode/wiki/Attaching-to-remote-processes#installing-vsdbg-on-the-server
* - exit
*
* 2. Configure docker so that port 22 is exposed (e.g. to port 2222), then test the connection:
* - ssh root@<docker-host> -p 2222
*
* 3. Replace <docker-host> below with the actual host
*/
"name": "Attach to Nexus (Docker)",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickRemoteProcess}",
"pipeTransport": {
"pipeProgram": "ssh",
"pipeArgs": [
"-T",
"[email protected]",
"-p",
"2222"
], // replace <docker host>
"debuggerPath": "~/vsdbg/vsdbg",
"pipeCwd": "${workspaceRoot}",
"quoteArgs": true
},
"justMyCode": false,
"sourceFileMap": {
/* Note: The absolute path comes from GitHub Actions.
* Change it if Nexus has been built somewhere else.
*/
"/home/runner/work/nexus/nexus": "${workspaceRoot}"
}
},
{
"name": "OpenAPI client generator",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build-generator",
"program": "${workspaceFolder}/artifacts/bin/Nexus.ClientGenerator/debug/Nexus.ClientGenerator.dll",
"args": [
"./"
],
"cwd": "${workspaceFolder}",
"stopAtEntry": false,
"console": "internalConsole"
}
],
}
11 changes: 11 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.analysis.extraPaths": [
"src/clients/python-client"
],
"dotnet.defaultSolution": "Nexus.sln"
}
Loading

0 comments on commit e1e25e3

Please sign in to comment.