|
| 1 | +name: Main |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - mvp |
| 8 | + tags: |
| 9 | + - '**' |
| 10 | + paths-ignore: |
| 11 | + - 'docs/**' |
| 12 | + - 'README.rst' |
| 13 | + - 'LICENSE.md' |
| 14 | + - 'publishing.md' |
| 15 | + pull_request: |
| 16 | + |
| 17 | +env: |
| 18 | + WEAVIATE_130: 1.30.2 |
| 19 | + WEAVIATE_131: 1.31.3 |
| 20 | + DOTNET_VERSION: '8.x' |
| 21 | + DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true |
| 22 | + DOTNET_CLI_TELEMETRY_OPTOUT: true |
| 23 | + |
| 24 | +jobs: |
| 25 | + check_formatting: |
| 26 | + name: Check Formatting |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - name: Checkout code |
| 30 | + uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Get list of changed C# files |
| 33 | + id: changed-files |
| 34 | + uses: tj-actions/changed-files@v46 |
| 35 | + with: |
| 36 | + files: | |
| 37 | + **.cs |
| 38 | +
|
| 39 | + - name: Setup .NET |
| 40 | + uses: actions/setup-dotnet@v4 |
| 41 | + with: |
| 42 | + dotnet-version: ${{ env.DOTNET_VERSION }} |
| 43 | + |
| 44 | + - name: Check formatting |
| 45 | + if: steps.changed-files.outputs.any_changed == 'true' |
| 46 | + run: | |
| 47 | + dotnet tool restore |
| 48 | + dotnet csharpier check ${{ steps.changed-files.outputs.all_changed_files }} |
| 49 | +
|
| 50 | + integration-tests: |
| 51 | + name: Run Integration Tests |
| 52 | + runs-on: ubuntu-latest |
| 53 | + strategy: |
| 54 | + fail-fast: false |
| 55 | + matrix: |
| 56 | + server: [ |
| 57 | + $WEAVIATE_130, |
| 58 | + $WEAVIATE_131 |
| 59 | + ] |
| 60 | + |
| 61 | + steps: |
| 62 | + - name: Check for required secrets |
| 63 | + run: | |
| 64 | + if [ -z "${{ secrets.DOCKER_USERNAME }}" ]; then echo "Warning: DOCKER_USERNAME is not set"; fi |
| 65 | + if [ -z "${{ secrets.DOCKER_PASSWORD }}" ]; then echo "Warning: DOCKER_PASSWORD is not set"; fi |
| 66 | + if [ -z "${{ secrets.NUGET_APIKEY }}" ]; then echo "Warning: NUGET_APIKEY is not set"; fi |
| 67 | +
|
| 68 | + - name: Checkout code |
| 69 | + uses: actions/checkout@v4 |
| 70 | + |
| 71 | + - name: Setup .NET |
| 72 | + uses: actions/setup-dotnet@v4 |
| 73 | + with: |
| 74 | + dotnet-version: ${{ env.DOTNET_VERSION }} |
| 75 | + |
| 76 | + - name: Cache NuGet packages |
| 77 | + uses: actions/cache@v4 |
| 78 | + with: |
| 79 | + path: ~/.nuget/packages |
| 80 | + key: ${{ runner.os }}-nuget-${{ hashFiles('**/.*proj') }} |
| 81 | + restore-keys: | |
| 82 | + ${{ runner.os }}-nuget- |
| 83 | +
|
| 84 | + - name: Restore dependencies |
| 85 | + run: dotnet restore |
| 86 | + |
| 87 | + - name: Login to Docker Hub |
| 88 | + uses: docker/login-action@v3 |
| 89 | + if: ${{ !github.event.pull_request.head.repo.fork && github.triggering_actor != 'dependabot[bot]' }} |
| 90 | + with: |
| 91 | + username: ${{secrets.DOCKER_USERNAME}} |
| 92 | + password: ${{secrets.DOCKER_PASSWORD}} |
| 93 | + |
| 94 | + - name: start weaviate |
| 95 | + run: /bin/bash ci/start_weaviate.sh ${{ matrix.server }} |
| 96 | + |
| 97 | + - name: Run integration tests |
| 98 | + run: dotnet test --no-restore |
| 99 | + |
| 100 | + - name: stop weaviate |
| 101 | + if: always() |
| 102 | + run: /bin/bash ci/stop_weaviate.sh ${{ matrix.server }} |
| 103 | + |
| 104 | + build-and-publish: |
| 105 | + name: Build and Publish to NuGet |
| 106 | + needs: [integration-tests] |
| 107 | + runs-on: ubuntu-latest |
| 108 | + if: startsWith(github.ref, 'refs/tags') |
| 109 | + permissions: |
| 110 | + contents: write |
| 111 | + steps: |
| 112 | + - name: Check for required secrets |
| 113 | + run: | |
| 114 | + if [ -z "${{ secrets.NUGET_APIKEY }}" ]; then echo "Warning: NUGET_APIKEY is not set"; fi |
| 115 | +
|
| 116 | + - name: Checkout code |
| 117 | + uses: actions/checkout@v4 |
| 118 | + with: |
| 119 | + fetch-depth: 0 |
| 120 | + fetch-tags: true |
| 121 | + |
| 122 | + - name: Setup .NET |
| 123 | + uses: actions/setup-dotnet@v4 |
| 124 | + with: |
| 125 | + dotnet-version: ${{ env.DOTNET_VERSION }} |
| 126 | + |
| 127 | + - name: Cache NuGet packages |
| 128 | + uses: actions/cache@v4 |
| 129 | + with: |
| 130 | + path: ~/.nuget/packages |
| 131 | + key: ${{ runner.os }}-nuget-${{ hashFiles('**/.*proj') }} |
| 132 | + restore-keys: | |
| 133 | + ${{ runner.os }}-nuget- |
| 134 | +
|
| 135 | + - name: Create NuGet package |
| 136 | + run: dotnet pack -c Release -o out src/Weaviate.Client/ |
| 137 | + |
| 138 | + - name: Push package to NuGet |
| 139 | + run: dotnet nuget push './out/*.nupkg' --skip-duplicate --api-key ${{ secrets.NUGET_APIKEY }} --source https://api.nuget.org/v3/index.json |
| 140 | + |
| 141 | + - name: GH Release |
| 142 | + uses: softprops/action-gh-release@v1 |
| 143 | + with: |
| 144 | + generate_release_notes: true |
| 145 | + draft: true |
| 146 | + files: ./out/*.nupkg |
0 commit comments