|
| 1 | +name: Test .NET Versions |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + |
| 6 | +jobs: |
| 7 | + test-dotnet-versions: |
| 8 | + name: Test on ${{ matrix.target-framework }} |
| 9 | + runs-on: ubuntu-latest |
| 10 | + |
| 11 | + strategy: |
| 12 | + fail-fast: false |
| 13 | + matrix: |
| 14 | + include: |
| 15 | + - target-framework: net6.0 |
| 16 | + dotnet-version: '6.0.x' |
| 17 | + - target-framework: net7.0 |
| 18 | + dotnet-version: '7.0.x' |
| 19 | + - target-framework: net8.0 |
| 20 | + dotnet-version: '8.0.x' |
| 21 | + - target-framework: net9.0 |
| 22 | + dotnet-version: '9.0.x' |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout code |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Setup .NET ${{ matrix.dotnet-version }} |
| 29 | + uses: actions/setup-dotnet@v4 |
| 30 | + with: |
| 31 | + dotnet-version: ${{ matrix.dotnet-version }} |
| 32 | + |
| 33 | + - name: Set up Docker Compose |
| 34 | + uses: docker/setup-compose-action@v1 |
| 35 | + |
| 36 | + - name: Start Docker Compose services |
| 37 | + working-directory: ./src/NullOpsDevs.LibSsh.Test |
| 38 | + run: docker compose up --build -d |
| 39 | + |
| 40 | + - name: Wait for SSH server to be ready |
| 41 | + run: | |
| 42 | + echo "Waiting for SSH server to start..." |
| 43 | + sleep 5 |
| 44 | +
|
| 45 | + - name: Setup SSH Agent |
| 46 | + run: | |
| 47 | + eval $(ssh-agent -s) |
| 48 | + echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK" >> $GITHUB_ENV |
| 49 | + echo "SSH_AGENT_PID=$SSH_AGENT_PID" >> $GITHUB_ENV |
| 50 | + cp src/NullOpsDevs.LibSsh.Test/docker/test-keys/id_rsa /tmp/id_rsa |
| 51 | + chmod 600 /tmp/id_rsa |
| 52 | + ssh-add /tmp/id_rsa |
| 53 | +
|
| 54 | + - name: Restore dependencies |
| 55 | + run: dotnet restore |
| 56 | + |
| 57 | + - name: Build library for ${{ matrix.target-framework }} |
| 58 | + run: dotnet build -c Release --no-restore -f ${{ matrix.target-framework }} |
| 59 | + |
| 60 | + - name: Build test project for ${{ matrix.target-framework }} |
| 61 | + run: dotnet build -c Release --self-contained -r linux-x64 -f ${{ matrix.target-framework }} ./src/NullOpsDevs.LibSsh.Test/NullOpsDevs.LibSsh.Test.csproj |
| 62 | + |
| 63 | + - name: Run tests |
| 64 | + working-directory: ./src/NullOpsDevs.LibSsh.Test/bin/Release/${{ matrix.target-framework }}/linux-x64/ |
| 65 | + run: ./NullOpsDevs.LibSsh.Test |
| 66 | + |
| 67 | + - name: Cleanup Docker Compose |
| 68 | + if: always() |
| 69 | + working-directory: ./src/NullOpsDevs.LibSsh.Test |
| 70 | + run: docker compose down -v |
0 commit comments