From 81208c0f03f7fa1d7b648cc854acb461a0311550 Mon Sep 17 00:00:00 2001 From: Serge Camille Date: Sun, 13 Sep 2020 10:02:16 +0200 Subject: [PATCH 1/9] Add github actions for multi-platform unit tests. --- .github/workflows/deploy.yml | 43 +++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 47 ++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..ae11e7a --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,43 @@ +name: Deploy + +on: + release: + types: release + +jobs: + deploy: + name: Deploy + needs: build_test + runs-on: windows-latest + if: ${{ false }} # not active right now + + steps: + - uses: actions/checkout@v2 + + - name: Fetch all history for all tags and branches + run: git fetch --prune --unshallow + + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v0.9.2 + with: + versionSpec: '5.2.x' + + - name: Use GitVersion + id: gitversion # step id used as reference for output values + uses: gittools/actions/gitversion/execute@v0.9.2 + + - name: Setup Dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '3.1.x' # SDK Version to use; x will use the latest version of the 3.1 channel + + - name: Pack + if: ${{ matrix.pack }} + run: dotnet pack --configuration "${{ env.configuration }}" /p:Version="${{ steps.gitversion.outputs.nuGetVersion }}" -o "${{ env.artifacts }}" + + - name: Upload Artifacts + if: ${{ matrix.pack }} + uses: actions/upload-artifact@v2 + with: + name: NugetPackage + path: ${{ env.artifacts }}/** diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..ad8397a --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,47 @@ +name: Test + +on: + [pull_request, push] + +jobs: + + build_test: + name: test-${{ matrix.os }}-${{ matrix.test-framework }} + runs-on: ${{ matrix.os }} + env: + configuration: Release + artifacts: ${{ github.workspace }}/artifacts + strategy: + matrix: + os: [windows-latest, ubuntu-latest, macos-latest] + test-framework: [netcoreapp3.1] + include: + - os: ubuntu-latest + installSnap7: true + - os: macos-latest + installSnap7: true + - os: windows-latest + test-framework: net452 + + steps: + - uses: actions/checkout@v2 + + - name: Install Snap7 Linux + if: ${{ matrix.installSnap7 && matrix.os == 'ubuntu-latest' }} + run: | + sudo add-apt-repository ppa:gijzelaar/snap7 + sudo apt-get update + sudo apt-get install libsnap7-1 libsnap7-dev + + - name: Install Snap7 MacOs + if: ${{ matrix.installSnap7 && matrix.os == 'macos-latest' }} + run: | + brew install snap7 + + - name: Setup Dotnet + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '3.1.x' # SDK Version to use; x will use the latest version of the 3.1 channel + + - name: Test + run: dotnet test --verbosity normal --logger GitHubActions --framework ${{ matrix.test-framework }} \ No newline at end of file From ce97fcf335fc4528a77852becdc1f300fabab0ec Mon Sep 17 00:00:00 2001 From: Serge Camille Date: Sun, 13 Sep 2020 10:42:19 +0200 Subject: [PATCH 2/9] Separate restore and test steps to better see execution times. Restore could be cached, but it looks quite complicated to pull off. --- .github/workflows/test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ad8397a..e94e324 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,5 +43,8 @@ jobs: with: dotnet-version: '3.1.x' # SDK Version to use; x will use the latest version of the 3.1 channel + - name: Restore + run: dotnet restore S7.Net.UnitTest + - name: Test - run: dotnet test --verbosity normal --logger GitHubActions --framework ${{ matrix.test-framework }} \ No newline at end of file + run: dotnet test --no-restore --verbosity normal --logger GitHubActions --framework ${{ matrix.test-framework }} \ No newline at end of file From fb44b56c164ac56b6e4f7063e65ef0a10ed730fd Mon Sep 17 00:00:00 2001 From: Serge Camille Date: Sun, 13 Sep 2020 10:54:16 +0200 Subject: [PATCH 3/9] Skip welcome message --- .github/workflows/deploy.yml | 4 +++- .github/workflows/test.yml | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ae11e7a..1b6ea18 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -9,6 +9,8 @@ jobs: name: Deploy needs: build_test runs-on: windows-latest + env: + DOTNET_NOLOGO : 1 if: ${{ false }} # not active right now steps: @@ -33,7 +35,7 @@ jobs: - name: Pack if: ${{ matrix.pack }} - run: dotnet pack --configuration "${{ env.configuration }}" /p:Version="${{ steps.gitversion.outputs.nuGetVersion }}" -o "${{ env.artifacts }}" + run: dotnet pack --nologo --configuration "${{ env.configuration }}" /p:Version="${{ steps.gitversion.outputs.nuGetVersion }}" -o "${{ env.artifacts }}" - name: Upload Artifacts if: ${{ matrix.pack }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e94e324..226aa6f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,7 @@ jobs: env: configuration: Release artifacts: ${{ github.workspace }}/artifacts + DOTNET_NOLOGO : 1 strategy: matrix: os: [windows-latest, ubuntu-latest, macos-latest] @@ -47,4 +48,4 @@ jobs: run: dotnet restore S7.Net.UnitTest - name: Test - run: dotnet test --no-restore --verbosity normal --logger GitHubActions --framework ${{ matrix.test-framework }} \ No newline at end of file + run: dotnet test --no-restore --nologo --verbosity normal --logger GitHubActions --framework ${{ matrix.test-framework }} \ No newline at end of file From ae70f31af25b540c56a77993d9e6ee900710c5d0 Mon Sep 17 00:00:00 2001 From: Serge Camille Date: Sat, 17 Oct 2020 11:47:16 +0200 Subject: [PATCH 4/9] Remove deploy workflow. --- .github/workflows/deploy.yml | 45 ------------------------------------ 1 file changed, 45 deletions(-) delete mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 1b6ea18..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Deploy - -on: - release: - types: release - -jobs: - deploy: - name: Deploy - needs: build_test - runs-on: windows-latest - env: - DOTNET_NOLOGO : 1 - if: ${{ false }} # not active right now - - steps: - - uses: actions/checkout@v2 - - - name: Fetch all history for all tags and branches - run: git fetch --prune --unshallow - - - name: Install GitVersion - uses: gittools/actions/gitversion/setup@v0.9.2 - with: - versionSpec: '5.2.x' - - - name: Use GitVersion - id: gitversion # step id used as reference for output values - uses: gittools/actions/gitversion/execute@v0.9.2 - - - name: Setup Dotnet - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '3.1.x' # SDK Version to use; x will use the latest version of the 3.1 channel - - - name: Pack - if: ${{ matrix.pack }} - run: dotnet pack --nologo --configuration "${{ env.configuration }}" /p:Version="${{ steps.gitversion.outputs.nuGetVersion }}" -o "${{ env.artifacts }}" - - - name: Upload Artifacts - if: ${{ matrix.pack }} - uses: actions/upload-artifact@v2 - with: - name: NugetPackage - path: ${{ env.artifacts }}/** From a23408d67ef968b54dacd637fc64611d284f2864 Mon Sep 17 00:00:00 2001 From: Serge Camille Date: Sat, 5 Jun 2021 17:58:05 +0200 Subject: [PATCH 5/9] Add Net5.0 to test matrix --- .github/workflows/test.yml | 2 +- S7.sln | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 226aa6f..fa94a91 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: strategy: matrix: os: [windows-latest, ubuntu-latest, macos-latest] - test-framework: [netcoreapp3.1] + test-framework: [netcoreapp3.1, net5.0] include: - os: ubuntu-latest installSnap7: true diff --git a/S7.sln b/S7.sln index 2ae0e52..dbfaf5c 100644 --- a/S7.sln +++ b/S7.sln @@ -9,6 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ProjectSection(SolutionItems) = preProject appveyor.yml = appveyor.yml README.md = README.md + .github\workflows\test.yml = .github\workflows\test.yml EndProjectSection EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "S7.Net.UnitTest", "S7.Net.UnitTest\S7.Net.UnitTest.csproj", "{303CCED6-9ABC-4899-A509-743341AAA804}" From fc9c33fdaf6bd350bdc973f709778f507f1dfbb8 Mon Sep 17 00:00:00 2001 From: Serge Camille Date: Sat, 5 Jun 2021 17:59:18 +0200 Subject: [PATCH 6/9] Add Net5.0 to test project as well. --- S7.Net.UnitTest/S7.Net.UnitTest.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/S7.Net.UnitTest/S7.Net.UnitTest.csproj b/S7.Net.UnitTest/S7.Net.UnitTest.csproj index e836b62..eb63e48 100644 --- a/S7.Net.UnitTest/S7.Net.UnitTest.csproj +++ b/S7.Net.UnitTest/S7.Net.UnitTest.csproj @@ -1,7 +1,7 @@  - net452;netcoreapp3.1 + net452;netcoreapp3.1;net5.0 true Properties\S7.Net.snk From 4541a7ebb77f89da95bb718be0ac938c16680e40 Mon Sep 17 00:00:00 2001 From: Serge Camille Date: Sat, 5 Jun 2021 18:11:06 +0200 Subject: [PATCH 7/9] Try adjusting the dotnet setup version. --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fa94a91..4bb5ea4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,6 +23,7 @@ jobs: installSnap7: true - os: windows-latest test-framework: net452 + fail-fast: false steps: - uses: actions/checkout@v2 @@ -42,7 +43,7 @@ jobs: - name: Setup Dotnet uses: actions/setup-dotnet@v1 with: - dotnet-version: '3.1.x' # SDK Version to use; x will use the latest version of the 3.1 channel + dotnet-version: '5.0.x' # SDK Version to use; x will use the latest version of the 3.1 channel - name: Restore run: dotnet restore S7.Net.UnitTest From bcde65120c4be54b24e1a1226c1878f5668c2235 Mon Sep 17 00:00:00 2001 From: Serge Camille Date: Sat, 5 Jun 2021 18:37:35 +0200 Subject: [PATCH 8/9] Github Actions Net5.0 (#1) * Try integrating dotnet setup version into build matrix. * Another attempt * change matrix. * don't add dotnet-sdk as main matrix variable * remove test framework as well. * or maybe not * Fix copy paste mixup --- .github/workflows/test.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4bb5ea4..f0b2569 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,11 +18,30 @@ jobs: test-framework: [netcoreapp3.1, net5.0] include: - os: ubuntu-latest + test-framework: netcoreapp3.1 installSnap7: true + dotnet-sdk: '3.1.x' + - os: ubuntu-latest + test-framework: net5.0 + installSnap7: true + dotnet-sdk: '5.0.x' - os: macos-latest + test-framework: netcoreapp3.1 installSnap7: true + dotnet-sdk: '3.1.x' + - os: macos-latest + test-framework: net5.0 + installSnap7: true + dotnet-sdk: '5.0.x' + - os: windows-latest + test-framework: netcoreapp3.1 + dotnet-sdk: '3.1.x' + - os: windows-latest + test-framework: net5.0 + dotnet-sdk: '5.0.x' - os: windows-latest test-framework: net452 + dotnet-sdk: '5.0.x' fail-fast: false steps: @@ -43,7 +62,7 @@ jobs: - name: Setup Dotnet uses: actions/setup-dotnet@v1 with: - dotnet-version: '5.0.x' # SDK Version to use; x will use the latest version of the 3.1 channel + dotnet-version: ${{ matrix.dotnet-sdk }} - name: Restore run: dotnet restore S7.Net.UnitTest From 5c24e801fddfac1783456240882ffaa56bb9dc6b Mon Sep 17 00:00:00 2001 From: Serge Camille Date: Sat, 5 Jun 2021 18:50:28 +0200 Subject: [PATCH 9/9] Add Actions Nuget Cache (#2) * Try out action cache * fix syntax error * Now lets see what happens if it hits the cache --- .github/workflows/test.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f0b2569..0d13810 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -63,9 +63,18 @@ jobs: uses: actions/setup-dotnet@v1 with: dotnet-version: ${{ matrix.dotnet-sdk }} + + - name: Nuget Cache + uses: actions/cache@v2 + with: + path: ~/.nuget/packages + # Look to see if there is a cache hit for the corresponding requirements file + key: ${{ runner.os }}-${{ matrix.test-framework }}-nuget-${{ hashFiles('**/packages.lock.json') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.test-framework }}-nuget - name: Restore run: dotnet restore S7.Net.UnitTest - name: Test - run: dotnet test --no-restore --nologo --verbosity normal --logger GitHubActions --framework ${{ matrix.test-framework }} \ No newline at end of file + run: dotnet test --no-restore --nologo --verbosity normal --logger GitHubActions --framework ${{ matrix.test-framework }}