Skip to content

Commit

Permalink
Initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
mtmk committed May 17, 2024
0 parents commit 17fac57
Show file tree
Hide file tree
Showing 95 changed files with 14,083 additions and 0 deletions.
357 changes: 357 additions & 0 deletions .editorconfig

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
* text=auto eol=lf
*.csproj text=auto eol=crlf

*.enc binary
*.eot binary
*.ico binary
*.jpg binary
*.otf binary
*.pem binary
*.pfx binary
*.png binary
*.ttf binary
*.woff binary
*.woff2 binary
*.pfx binary
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
blank_issues_enabled: false
contact_links:
- name: Discussion
url: https://github.com/nats-io/nkeys.net/discussions
about: Ideal for ideas, feedback, or longer form questions.
- name: Chat
url: https://slack.nats.io
about: Ideal for short, one-off questions, general conversation, and meeting other NATS users!
44 changes: 44 additions & 0 deletions .github/ISSUE_TEMPLATE/defect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Defect
description: Report a defect, such as a bug or regression.
labels:
- defect
body:
- type: textarea
id: observed
attributes:
label: Observed behavior
description: Describe the unexpected behavior or performance regression you are observing.
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected behavior
description: Describe the expected behavior or performance characteristics.
validations:
required: true
- type: textarea
id: versions
attributes:
label: Library version
description: |-
Provide the version you were using when the detect was observed.
validations:
required: true
- type: textarea
id: environment
attributes:
label: Host environment
description: |-
Specify any relevant details about the host environment the library was running in,
such as operating system, CPU architecture, container runtime, etc.
validations:
required: false
- type: textarea
id: steps
attributes:
label: Steps to reproduce
description: Provide as many concrete steps to reproduce the defect.
validations:
required: false
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/proposal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: Proposal
description: Propose an enhancement or new feature.
labels:
- proposal
body:
- type: textarea
id: change
attributes:
label: Proposed change
description: This could be a behavior change, enhanced API, or a new feature.
validations:
required: true
- type: textarea
id: usecase
attributes:
label: Use case
description: What is the use case or general motivation for this proposal?
validations:
required: true
- type: textarea
id: contribute
attributes:
label: Contribution
description: |-
Are you intending or interested in contributing code for this proposal if accepted?
validations:
required: false
30 changes: 30 additions & 0 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Format

on:
pull_request: {}

# to be removed. only needed for the initial setup. running on pull requests is enough.
push: { branches: [ main ] }

jobs:
check:
name: check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'

- name: Check formatting
run: |
if dotnet format --verify-no-changes; then
echo "formatting passed"
else
rc="$?"
echo "formatting failed; run 'dotnet format'" >&2
exit "$rc"
fi
57 changes: 57 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Release

on:
push:
branches:
- main

permissions:
contents: write

jobs:
nuget:
name: dotnet
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- id: tag
name: Determine tag
run: |
version="$(head -n 1 version.txt)"
ref_name="v$version"
create=true
if [ "$(git ls-remote origin "refs/tags/$ref_name" | wc -l)" = "1" ]; then
create=false
fi
echo "version=$version" | tee -a "$GITHUB_OUTPUT"
echo "ref-name=$ref_name" | tee -a "$GITHUB_OUTPUT"
echo "create=$create" | tee -a "$GITHUB_OUTPUT"
- if: ${{ fromJSON(steps.tag.outputs.create) }}
name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.x'

- if: ${{ fromJSON(steps.tag.outputs.create) }}
name: Pack
# https://learn.microsoft.com/en-us/nuget/create-packages/symbol-packages-snupkg
# https://devblogs.microsoft.com/dotnet/producing-packages-with-source-link/
run: dotnet pack -c Release -o dist -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg -p:ContinuousIntegrationBuild=true

- if: ${{ fromJSON(steps.tag.outputs.create) }}
name: Push
run: |
cd dist
ls -lh
# this should upload snupkgs in the same folder
# dotnet nuget push *.nupkg -s https://api.nuget.org/v3/index.json -k "${{ secrets.NUGET_API_KEY }}" --skip-duplicate
- if: ${{ fromJSON(steps.tag.outputs.create) }}
name: Tag
run: |
git tag "${{ steps.tag.outputs.ref-name }}"
git push origin "${{ steps.tag.outputs.ref-name }}"
100 changes: 100 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Test

on:
pull_request: {}
push:
branches:
- main

jobs:
dotnet:
name: dotnet
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: |
6.x
8.x
- name: Build
run: dotnet build -c Debug

- name: Test Core
run: dotnet test -c Debug --no-build --logger:"console;verbosity=normal"

- name: Check Native AOT
shell: bash
run: |
echo ">> Set up for AOT compilation..."
export exe_file=NATS.NKeys.CheckNativeAot
export exe_type=ELF
export dotnet_runtime_id=linux-x64
echo ">> Checking OS..."
if [ "${{ matrix.os }}" = "windows-latest" ]; then
export exe_file=NATS.NKeys.CheckNativeAot.exe
export exe_type=PE32
export dotnet_runtime_id=win-x64
elif [ "${{ matrix.os }}" = "macos-latest" ]; then
export dotnet_runtime_id=osx-x64
export exe_type=Mach-O
fi
echo ">> Publishing..."
cd NATS.NKeys.CheckNativeAot
rm -rf bin obj
dotnet publish -r $dotnet_runtime_id -c Release -o dist | tee output.txt
echo ">> Checking for warnings..."
grep -i warning output.txt && exit 1
echo ">> Executable sanity checks..."
cd dist
ls -lh
echo ">> Executable is of type $exe_type..."
file $exe_file
file $exe_file | grep $exe_type || exit 1
echo ">> Executable size checks..."
# Can't be less than a meg and not more than 10 megs.
# Fairly arbitrary, but we want to make sure executable size
# is reasonable so we can be somewhat sure AOT compilation
# happened correctly.
export filesize=0
if [ "${{ matrix.os }}" = "windows-latest" ]; then
export filesize=$(stat -c %s $exe_file)
elif [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
export filesize=$(stat -c %s $exe_file)
elif [ "${{ matrix.os }}" = "macos-latest" ]; then
export filesize=$(stat -f %z $exe_file)
fi
echo ">> File size: $filesize bytes"
if [ $filesize -lt 1048576 ]; then
echo ">> Error: File is less than 1MB."
exit 1
fi
if [ $filesize -gt 10485760 ]; then
echo ">> Error: File is more than 10MB."
exit 1
fi
echo ">> File size is within acceptable range."
echo ">> Running executable..."
./$exe_file | tee | grep PASS || exit 1
echo ">> Run complete."
Loading

0 comments on commit 17fac57

Please sign in to comment.