TLSharp/.github/workflows/CI.yml
Andres Aragoneses cec35c6004 Run tests in CI (Windows OS only for now)
The reason for such a hack when runing in CI is because we
need to make sure we're using higher sequence numbers than
any previous times (and even previous runs of the test suite).

And we run 1 test only for now, later we will enable more.

Other notes:

The trick to extract secrets to files was taken from:
https://stackoverflow.com/a/59482124/544947

The binary-to-text encoding/decoding was taken from:
https://stackoverflow.com/a/42725926/544947

The way to add defines to DefineConstants for MSBuild:
https://stackoverflow.com/a/5053070/544947
2020-09-19 17:00:34 +08:00

70 lines
1.9 KiB
YAML

name: CI
on: [push, pull_request]
env:
NUGET_URL: https://dist.nuget.org/win-x86-commandline/v5.4.0/nuget.exe
jobs:
linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Download latest NuGet
run: wget $NUGET_URL
- name: Install Dependencies
run: mono nuget.exe restore src/TgSharp.sln
- name: Build Project
run: xbuild src/TgSharp.sln
macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Download latest NuGet
run: curl -o nuget.exe $NUGET_URL
- name: Install Dependencies
run: mono nuget.exe restore src/TgSharp.sln
- name: Build Project
run: msbuild src/TgSharp.sln
windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Download Nuget.exe
run: Invoke-WebRequest -OutFile Nuget.exe $Env:NUGET_URL
- name: Install Dependencies
run: ./Nuget.exe restore src/TgSharp.sln
- name: setup-msbuild
uses: microsoft/setup-msbuild@v1
- name: Build Project
run: MSBuild src/TgSharp.sln && MSBuild -t:Clean src/TgSharp.sln
- name: Prepare test suite assets
run: |
echo "$APP_CONFIG_IN_TESTS" > app.config
echo "$SESSION_DAT_IN_TESTS" > encodedSession.dat
shell: bash
env:
APP_CONFIG_IN_TESTS: ${{secrets.APP_CONFIG_IN_TESTS}}
SESSION_DAT_IN_TESTS: ${{secrets.SESSION_DAT_IN_TESTS}}
- name: Run Tests
run: |
MSBuild -p:Configuration=Debug -p:CI=true src/TgSharp.sln
certutil -decode encodedSession.dat src/TgSharp.Tests.NUnit/bin/Debug/session.dat
cp app.config src/TgSharp.Tests.NUnit/bin/Debug/TgSharp.Tests.NUnit.dll.config
./Nuget.exe install NUnit.Runners -Version 3.11.1 -OutputDirectory packages
./packages/NUnit.ConsoleRunner.3.11.1/tools/nunit3-console.exe src/TgSharp.Tests.NUnit/bin/Debug/TgSharp.Tests.NUnit.dll