Skip to content

Commit

Permalink
Merge pull request #23 from adam-p/github-action
Browse files Browse the repository at this point in the history
Add test and Windows build GitHub actions
  • Loading branch information
adam-p authored Apr 9, 2022
2 parents 19e57ef + 1f84536 commit 656ebba
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 5 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# On release, make a Windows release build and attach it to the release
name: Windows Release Build

on:
release:
types: [published]

jobs:
build:
permissions:
# Required for release binary upload
contents: write

runs-on: windows-2019

steps:
- uses: actions/checkout@v3

- uses: egor-tensin/vs-shell@v2
with:
arch: x86

- name: Run build script
working-directory: ${{env.GITHUB_WORKSPACE}}
run: .\build-windows.bat

- name: Create zip
run: 7z a dist-windows.zip dist-windows

- uses: AButler/[email protected]
with:
files: 'dist-windows.zip'
repo-token: ${{ secrets.GITHUB_TOKEN }}
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Run test.sh
name: Run Tests

on:
push:
pull_request:

jobs:
test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- run: sudo apt update && sudo apt install -y cmake

- name: Extract SecretTestValues.h
run: echo ${{ secrets.SECRET_TEST_VALUES }} | base64 -d > ./SecretTestValues.h
shell: bash

- name: test
run: bash ./test.sh
3 changes: 2 additions & 1 deletion build-windows.bat
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ cmake -G "Visual Studio 16 2019" -A Win32 ..
if "%ERRORLEVEL%" == "1" exit /B 1

REM Build for Debug and MinSizeRel
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat"
REM This doesn't need to be called in the GitHub Action build
if "%GITHUB_ACTION%" == "" call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat"
if "%ERRORLEVEL%" == "1" exit /B 1
msbuild.exe -p:Configuration=Debug -p:PlatformToolset=v140 -p:PreferredToolArchitecture=x86 -p:Platform=x86 -p:PlatformTarget=x86 psicash.vcxproj
if "%ERRORLEVEL%" == "1" exit /B 1
Expand Down
14 changes: 10 additions & 4 deletions datastore_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,11 @@ TEST_F(TestDatastore, SetWriteDedup)
ASSERT_FALSE(err);
auto file_time3 = std::filesystem::last_write_time(ds_path);

// The file should have been updated, so its time should be newer
ASSERT_GT(file_time3, file_time1);
// When running under Docker (i.e., GitHub Actions), the the file times don't change
if (std::getenv("GITHUB_ACTION") == nullptr) {
// The file should have been updated, so its time should be newer
ASSERT_GT(file_time3, file_time1);
}
}

TEST_F(TestDatastore, TransactionWriteDedup)
Expand Down Expand Up @@ -641,8 +644,11 @@ TEST_F(TestDatastore, TransactionWriteDedup)
ASSERT_FALSE(err);
auto file_time3 = std::filesystem::last_write_time(ds_path);

// The file should have been updated, so its time should be newer
ASSERT_GT(file_time3, file_time1);
// When running under Docker (i.e., GitHub Actions), the the file times don't change
if (std::getenv("GITHUB_ACTION") == nullptr) {
// The file should have been updated, so its time should be newer
ASSERT_GT(file_time3, file_time1);
}

ds.BeginTransaction();

Expand Down

0 comments on commit 656ebba

Please sign in to comment.