Skip to content

Commit

Permalink
Add Hashset (#1)
Browse files Browse the repository at this point in the history
* feat: in memory implementation

* feat: redis implementation

* test: add tests for AddAsync

* test: add tests for AddAsync + RemoveAsync

* test: add tests for ContainsAsync

* test: add tests for CountAsync

* test: add tests for LongCountAsync

* test: refactor redis tests to dispose ephemeral db

* test: add test for ClearAsync

* chore: update ephemerally

* test: fix redis tests to actually dispose ephemeral db

* test: add test for IAsyncEnumerable

* chore: ci workflows

* chore: remove unused usings

* chore: fix redis test project dir

* chore: ci changes

* chore: ci changes

* chore: push to nuget.org
  • Loading branch information
Confusingboat authored Apr 2, 2024
1 parent 9a404b1 commit a0aaee6
Show file tree
Hide file tree
Showing 19 changed files with 1,055 additions and 0 deletions.
185 changes: 185 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
name: Build, Test, Release

on:
workflow_dispatch:
push:
tags:
- '*'
branches:
- 'main'
- 'gh-actions*'
pull_request:
branches:
- '*'

env:
TIMEZONE: 'America/Chicago'
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
ArtifactDirectory: ${{ github.workspace}}/artifacts

defaults:
run:
shell: pwsh

jobs:
build_and_test:
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
steps:
- uses: actions/checkout@v2

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8
dotnet-quality: ga

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore --configuration:Release

- name: Test Core
if: ${{ always() && github.event_name == 'pull_request' || github.ref == 'refs/heads/main' }}
run: |
dotnet test 'tests\Distributed.Collections.Tests\' `
--no-build `
--configuration:Release `
--logger:trx `
--results-directory ${{ env.ArtifactDirectory }}
- name: Test Redis
if: ${{ always() && github.event_name == 'pull_request' || github.ref == 'refs/heads/main' }}
run: |
dotnet test 'tests\Distributed.Collections.Redis.Tests\' `
--no-build `
--configuration:Release `
--logger:trx `
--results-directory ${{ env.ArtifactDirectory }}
- name: Upload Test Results
if: ${{ always() && github.event_name == 'pull_request' || github.ref == 'refs/heads/main' }}
uses: actions/upload-artifact@v4
with:
name: test-results
path: ${{ env.ArtifactDirectory }}/**/*.trx

# Cosmos DB Emulator is broken on Ubuntu
# https://github.com/Azure/azure-cosmos-db-emulator-docker/issues/56

build_and_test_cosmos:
if: false
runs-on: windows-2022
permissions:
checks: write
pull-requests: write
# Reenable when Ubuntu is fixed
# services:
# cosmos:
# image: mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
# ports:
# - 8081:8081
# - 10250-10255:10250-10255
# env:
# AZURE_COSMOS_EMULATOR_PARTITION_COUNT: 3
# AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE: true
steps:
- uses: actions/checkout@v2

# Remove when Ubuntu is fixed
- name: Start Cosmos DB Emulator
if: ${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' }}
uses: southpolesteve/cosmos-emulator-github-action@v1

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8
dotnet-quality: ga

- name: Restore dependencies
run: dotnet restore

- name: Build
run: dotnet build --no-restore --configuration:Release

# Reenable when Ubuntu is fixed
# - name: Wait for Cosmos Emulator
# uses: cygnetdigital/[email protected]
# with:
# url: 'https://localhost:8081/_explorer/index.html'
# responseCode: '200,500'
# timeout: 5000
# interval: 500

- name: Test Cosmos
if: ${{ github.event_name == 'pull_request' || github.ref == 'refs/heads/main' }}
run: |
dotnet test 'tests\Distributed.Collections.Azure.Cosmos.Tests\' `
--no-build `
--configuration:Release `
--logger:trx `
--results-directory ${{ env.ArtifactDirectory }}
- name: Upload Test Results
if: ${{ always() && github.event_name == 'pull_request' || github.ref == 'refs/heads/main' }}
uses: actions/upload-artifact@v4
with:
name: cosmos-test-results
path: ${{ env.ArtifactDirectory }}/**/*.trx

test_results_comment:
if: ${{ always() && github.event_name == 'pull_request' || github.ref == 'refs/heads/main' }}
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write
needs:
- build_and_test
#- build_and_test_cosmos

steps:
- name: Download Test Results
uses: actions/download-artifact@v4
with:
path: ${{ env.ArtifactDirectory }}

- name: Test Results Comment
uses: im-open/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
timezone: ${{ env.TIMEZONE }}
create-status-check: false
create-pr-comment: true
comment-identifier: 'TestResults'

tag:
if: ${{ github.event_name != 'pull_request' }}
uses: ./.github/workflows/tag.yml

test-tag-output:
runs-on: ubuntu-latest
needs:
- tag
steps:
- name: Echo tag output
run: |
echo version: "${{ needs.tag.outputs.version }}"
echo prerelease-depth: "${{ fromJSON(needs.tag.outputs.prerelease-depth) }}"
echo is-prerelease: "${{ fromJSON(needs.tag.outputs.is-prerelease) }}"
release:
needs:
- tag
- build_and_test
#- build_and_test_cosmos
if: ${{ github.ref_type == 'tag' || github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && fromJSON(needs.tag.outputs.prerelease-depth) < 2 }}
uses: ./.github/workflows/release.yml
with:
version: ${{ needs.tag.outputs.version }}
is-prerelease: ${{ fromJSON(needs.tag.outputs.is-prerelease) }}
secrets: inherit
69 changes: 69 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Pack & Release

on:
workflow_call:
inputs:
version:
required: true
type: string
is-prerelease:
required: true
type: boolean
secrets:
NUGET_ORG_API_KEY:
required: true
env:
MinVerVersionOverride: ${{ inputs.version }}
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true
ArtifactDirectory: ${{ github.workspace }}/artifacts

defaults:
run:
shell: pwsh

jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- run: |
dotnet nuget add source `
--username USERNAME `
--password ${{ secrets.GITHUB_TOKEN }} `
--store-password-in-clear-text `
--name github "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
- run: |
dotnet pack `
-c Release `
-o ${{ env.ArtifactDirectory }} `
/p:RepositoryUrl="${{ github.server_url }}/${{ github.repository }}" `
/p:Authors=${{ github.repository_owner }}
- name: Echo artifact directory
run: |
echo ${{ env.ArtifactDirectory }}
ls ${{ env.ArtifactDirectory }}
- name: Create GitHub release
id: release
uses: ncipollo/release-action@v1
with:
tag: v${{ inputs.version }}
prerelease: ${{ inputs.is-prerelease }}
artifacts: "${{ env.ArtifactDirectory }}/*.nupkg"

- name: Publish to pkg.github.com
run: |
dotnet nuget push "${{ env.ArtifactDirectory }}/*.nupkg" -s "github"
- name: Publish to nuget.org
run: |
dotnet nuget push "${{ env.ArtifactDirectory }}/*.nupkg" -k ${{ secrets.NUGET_ORG_API_KEY }} -s https://api.nuget.org/v3/index.json
102 changes: 102 additions & 0 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: Tag

on:
workflow_call:
outputs:
version:
description: "Generated version"
value: ${{ jobs.tag.outputs.version }}
major:
description: "Generated major version"
value: ${{ jobs.tag.outputs.major }}
minor:
description: "Generated minor version"
value: ${{ jobs.tag.outputs.minor }}
patch:
description: "Generated patch version"
value: ${{ jobs.tag.outputs.patch }}
prerelease:
description: "Generated prerelease version"
value: ${{ jobs.tag.outputs.prerelease }}
prerelease-depth:
description: "Number of periods in the prerelease version"
value: ${{ jobs.tag.outputs.prerelease-depth }}
is-prerelease:
description: "Boolean string indicating whether the version is a prerelease"
value: ${{ jobs.tag.outputs.is-prerelease }}

env:
#MinVerIgnoreHeight: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
DOTNET_NOLOGO: true

jobs:
tag:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
major: ${{ steps.version.outputs.major }}
minor: ${{ steps.version.outputs.minor }}
patch: ${{ steps.version.outputs.patch }}
prerelease: ${{ steps.version.outputs.prerelease }}
prerelease-depth: ${{ steps.set-prerelease-depth.outputs.prerelease_depth }}
is-prerelease: ${{ steps.set-is-prerelease.outputs.is_prerelease }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: action-minver-refreshed
id: version
uses: Stelzi79/[email protected]
with:
minver-version: 4.3.0
auto-increment: patch
tag-prefix: v
default-pre-release-phase: preview

- name: Echo version #version major minor patch prerelease
run: |
echo version: ${{ steps.version.outputs.version }}
echo major: ${{ steps.version.outputs.major }}, minor: ${{ steps.version.outputs.minor }}, patch: ${{ steps.version.outputs.patch }}
echo prerelease: ${{ steps.version.outputs.prerelease }}
- name: Set prerelease depth
id: set-prerelease-depth
run: |
echo "prerelease_depth=$(echo '${{ steps.version.outputs.prerelease }}' | tr -cd '.' | wc -c | tr -d ' ')" >> "$GITHUB_OUTPUT"
- name: Echo prerelease depth
run: echo "${{ steps.set-prerelease-depth.outputs.prerelease_depth }}"

- name: Set is-prerelease
id: set-is-prerelease
run: |
echo "is_prerelease=$(echo '${{ contains(steps.version.outputs.version, '-') && 'true' || 'false' }}')" >> "$GITHUB_OUTPUT"
- name: Echo is-prerelease
run: echo "${{ steps.set-is-prerelease.outputs.is_prerelease }}"

- name: Tag version
if: ${{ github.ref == 'refs/heads/main' }}
run: |
git tag v${{ steps.version.outputs.version }}
git push --tags
# Update unstable tag on main branch
- name: Tag unstable
if: ${{ github.ref_type == 'tag' || github.ref == 'refs/heads/main' }}
uses: EndBug/[email protected]
with:
ref: unstable

# Update latest tag on main branch when tagged RTM
- name: Tag latest
if: ${{ github.ref_type == 'tag' || github.ref == 'refs/heads/main' && steps.version.outputs.prerelease == '' }}
uses: EndBug/[email protected]

# - name: Tag version
# if: ${{ github.ref == 'refs/heads/main' }}
# uses: EndBug/[email protected]
# with:
# ref: v${{ steps.version.outputs.version }}
Loading

0 comments on commit a0aaee6

Please sign in to comment.