Migrate Windows CI to GitHub Actions

AppVeyor is breaking my builds because I can't create any more artifacts
because I've hit the limit, but there's no way to have it not store
artifacts or to manually delete artifacts...

This also updates Boost from 1.67.0 to 1.69.0 due to differences between
the AppVeyor and GitHub Actions build environments.
This commit is contained in:
Oliver Hamlet
2020-08-14 23:39:59 +01:00
parent 6e43be662f
commit 5c2dd2167d
7 changed files with 293 additions and 149 deletions
+121
View File
@@ -0,0 +1,121 @@
name: CI
on:
push:
# Don't run this workflow when a tag is pushed.
branches:
- '*'
pull_request:
env:
CARGO_TERM_COLOR: always
CBINDGEN_VERSION: 0.13.2
MSVC_CONFIG: RelWithDebInfo
jobs:
bintray-cleanup:
runs-on: ubuntu-18.04
steps:
- name: Remove old artifacts from Bintray
shell: bash
run: |
curl -sfSLO 'https://raw.githubusercontent.com/Ortham/ci-scripts/2.1.4/delete_old_bintray_versions.py'
python3 delete_old_bintray_versions.py -g loot/libloot -b loot/snapshots/libloot -u wrinklyninja -k ${{ secrets.BINTRAY_API_KEY }} -t ${{ secrets.GITHUB_TOKEN }} -n 30
if: github.event_name == 'push'
windows:
runs-on: windows-2016
strategy:
matrix:
platform: [Win32, x64]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Cache cargo
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cbindgen
id: cache-cbindgen
uses: actions/cache@v2
with:
path: ~/.cargo/bin/cbindgen.exe
key: ${{ runner.os }}-cbindgen-${{ env.CBINDGEN_VERSION }}
- name: Install Rust i686-pc-windows-msvc target
run: rustup target add i686-pc-windows-msvc
- name: Install cbindgen
run: |
cargo install cbindgen --version ${{ env.CBINDGEN_VERSION }}
echo "::add-path::~/.cargo/bin"
if: steps.cache-cbindgen.outputs.cache-hit != 'true'
- name: Get descriptive libloot version
id: get-libloot-version
shell: bash
run: |
GIT_DESCRIBE=$(git describe --tags --long --abbrev=7)
GIT_REF=${{ github.ref }}
LIBLOOT_DESC_REF=${GIT_DESCRIBE}_${GIT_REF#refs/*/}
LIBLOOT_SAFE_DESC_REF=${LIBLOOT_DESC_REF//[\/<>\"|]/_}
echo "::set-output name=version::$LIBLOOT_SAFE_DESC_REF"
- name: Run CMake
run: |
mkdir build
cd build
cmake .. -G "Visual Studio 15 2017" -A ${{ matrix.platform }} -DBOOST_ROOT="${env:BOOST_ROOT_1_69_0}" -DBOOST_LIBRARYDIR="${env:BOOST_ROOT_1_69_0}\lib" -DCPACK_PACKAGE_VERSION="${{ steps.get-libloot-version.outputs.version }}"
cmake --build . --config ${{ env.MSVC_CONFIG }}
- name: Run tests
run: |
cd build/${{ env.MSVC_CONFIG }}
git config --global user.email "github@github-actions"
git config --global user.name "GitHub"
.\libloot_internals_tests.exe
.\libloot_tests.exe
- name: Install packages for building docs
run: |
nuget install doxygen -Version 1.8.14
echo "::add-path::${{ github.workspace }}\Doxygen.1.8.14\tools"
python -m pip install -r docs/requirements.txt
- name: Build docs
run: ${{ runner.tool_cache }}\Python\3.7.8\x64\Scripts\sphinx-build -b html docs build\docs\html
- name: Build archive
id: build-archive
shell: bash
run: |
cd build
cpack -C ${{ env.MSVC_CONFIG }}
VERSION="${{ steps.get-libloot-version.outputs.version }}"
if [[ "${{ matrix.platform }}" == "Win32" ]]
then
PLATFORM=win32
else
PLATFORM=win64
fi
echo "::set-output name=filename::libloot-${VERSION}-${PLATFORM}.7z"
- name: Upload archive to BinTray
shell: bash
run: |
VERSION="${{ steps.get-libloot-version.outputs.version }}"
FILENAME="${{ steps.build-archive.outputs.filename }}"
curl -sfSL -T "build/package/$FILENAME" -u "wrinklyninja:${{ secrets.BINTRAY_API_KEY }}" "https://bintray.com/api/v1/content/loot/snapshots/libloot/${VERSION}/${FILENAME}?publish=1&override=1"
if: github.event_name == 'push'
+131
View File
@@ -0,0 +1,131 @@
name: Release
on:
push:
tags: '*'
env:
CARGO_TERM_COLOR: always
CBINDGEN_VERSION: 0.13.2
MSVC_CONFIG: RelWithDebInfo
jobs:
create_release:
runs-on: ubuntu-18.04
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
git_tag: ${{ steps.get-git-tag.outputs.name }}
steps:
- name: Get Git tag
id: get-git-tag
run: |
GIT_REF=${{ github.ref }}
echo "::set-output name=name::${GIT_REF#refs/*/}"
- id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get-git-tag.outputs.name }}
release_name: libloot v${{ steps.get-git-tag.outputs.name }}
body: |
Requires Windows 7 or later and the [MSVC 2017 x86 redistributable](https://download.visualstudio.microsoft.com/download/pr/749aa419-f9e4-4578-a417-a43786af205e/d59197078cc425377be301faba7dd87a/vc_redist.x86.exe), and [7-Zip](http://www.7-zip.org/) to extract the archives.
## Change Logs
- [API](https://loot-api.readthedocs.io/en/latest/api/changelog.html)
- [Metadata Syntax](https://loot-api.readthedocs.io/en/latest/metadata/changelog.html)
*Note: The files below with `tar.xz` extensions contain Linux binaries. They won't work on Windows computers.*
windows:
runs-on: windows-2016
needs: create_release
strategy:
matrix:
platform: [Win32, x64]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Cache cargo
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cbindgen
id: cache-cbindgen
uses: actions/cache@v2
with:
path: ~/.cargo/bin/cbindgen.exe
key: ${{ runner.os }}-cbindgen-${{ env.CBINDGEN_VERSION }}
- name: Install Rust i686-pc-windows-msvc target
run: rustup target add i686-pc-windows-msvc
- name: Install cbindgen
run: |
cargo install cbindgen --version ${{ env.CBINDGEN_VERSION }}
echo "::add-path::~/.cargo/bin"
if: steps.cache-cbindgen.outputs.cache-hit != 'true'
- name: Get descriptive libloot version
id: get-libloot-version
shell: bash
run: |
GIT_DESCRIBE=$(git describe --tags --long --abbrev=7)
GIT_REF=${{ github.ref }}
LIBLOOT_DESC_REF=${GIT_DESCRIBE}_${GIT_REF#refs/*/}
LIBLOOT_SAFE_DESC_REF=${LIBLOOT_DESC_REF//[\/<>\"|]/_}
echo "::set-output name=version::$LIBLOOT_SAFE_DESC_REF"
- name: Run CMake
run: |
mkdir build
cd build
cmake .. -G "Visual Studio 15 2017" -A ${{ matrix.platform }} -DBOOST_ROOT="${env:BOOST_ROOT_1_69_0}" -DBOOST_LIBRARYDIR="${env:BOOST_ROOT_1_69_0}\lib" -DCPACK_PACKAGE_VERSION="${{ steps.get-libloot-version.outputs.version }}"
cmake --build . --config ${{ env.MSVC_CONFIG }}
- name: Install packages for building docs
run: |
nuget install doxygen -Version 1.8.14
echo "::add-path::${{ github.workspace }}\Doxygen.1.8.14\tools"
python -m pip install -r docs/requirements.txt
- name: Build docs
run: ${{ runner.tool_cache }}\Python\3.7.8\x64\Scripts\sphinx-build -b html docs build\docs\html
- name: Build archive
id: build-archive
shell: bash
run: |
cd build
cpack -C ${{ env.MSVC_CONFIG }}
VERSION="${{ steps.get-libloot-version.outputs.version }}"
if [[ "${{ matrix.platform }}" == "Win32" ]]
then
PLATFORM=win32
else
PLATFORM=win64
fi
echo "::set-output name=filename::libloot-${VERSION}-${PLATFORM}.7z"
- name: Upload Archive
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ needs.create_release.outputs.upload_url }}
asset_path: build/package/${{ steps.build-archive.outputs.filename }}
asset_name: ${{ steps.build-archive.outputs.filename }}
asset_content_type: application/x-7z-compressed
+5 -6
View File
@@ -36,8 +36,10 @@ install:
before_script:
- mkdir build
- cd build
# Link dynamically to the C++ standard library runtime.
- cmake .. -DBOOST_ROOT=~/boost_1_67_0
# Get the full repo history before trying to run git describe.
- git fetch --unshallow
- export PACKAGE_VERSION=$(git describe --tags --long --always --abbrev=7)_${TRAVIS_BRANCH}
- cmake .. -DBOOST_ROOT=~/boost_1_67_0 -DCPACK_PACKAGE_VERSION=$PACKAGE_VERSION
script:
- make all
@@ -53,13 +55,10 @@ after_success:
- cd build
- cpack
- cd ..
# Get the full repo history before trying to run git describe.
- git fetch --unshallow
- GIT_DESCRIBE=$(git describe --tags --long --always --abbrev=7)
# Make copies of the archives for GitHub deployment to find.
- cp $(ls build/package/libloot-*.tar.xz) build/libloot.tar.xz
# Need to replace the Bintray config files' version placeholders.
- sed -i "s/REPLACE_THIS_VERSION/${GIT_DESCRIBE}_${TRAVIS_BRANCH}/" scripts/travis/libloot.bintray.json
- sed -i "s/REPLACE_THIS_VERSION/${PACKAGE_VERSION}/" scripts/travis/libloot.bintray.json
deploy:
- provider: bintray
+12 -15
View File
@@ -54,7 +54,7 @@ IF (NOT Boost_USE_STATIC_LIBS)
ENDIF ()
IF (CMAKE_SYSTEM_NAME MATCHES "Windows")
IF (NOT "${CMAKE_GENERATOR}" MATCHES "(Win64|IA64)")
IF ("${CMAKE_GENERATOR_PLATFORM}" MATCHES "Win32")
set(RUST_TARGET i686-pc-windows-msvc)
ELSE ()
set(RUST_TARGET x86_64-pc-windows-msvc)
@@ -499,20 +499,18 @@ install(DIRECTORY "${CMAKE_BINARY_DIR}/docs/html/"
# CPack
########################################
IF (GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --long --always --abbrev=7
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_DESCRIBE_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE)
IF (NOT DEFINED CPACK_PACKAGE_VERSION)
IF (GIT_FOUND)
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --long --always --abbrev=7
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_DESCRIBE_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE)
ELSE()
SET (GIT_DESCRIBE_STRING "unknown-version")
ENDIF ()
IF (DEFINED ENV{APPVEYOR_REPO_BRANCH})
set(GIT_DESCRIBE_STRING "${GIT_DESCRIBE_STRING}_$ENV{APPVEYOR_REPO_BRANCH}")
ELSEIF (DEFINED ENV{TRAVIS_BRANCH})
set(GIT_DESCRIBE_STRING "${GIT_DESCRIBE_STRING}_$ENV{TRAVIS_BRANCH}")
ENDIF()
ELSE()
SET (GIT_DESCRIBE_STRING "unknown-version")
ENDIF ()
set(CPACK_PACKAGE_VERSION ${GIT_DESCRIBE_STRING})
ENDIF()
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
set(CPACK_GENERATOR "7Z")
@@ -520,7 +518,6 @@ else()
set(CPACK_GENERATOR "TXZ")
endif()
set(CPACK_PACKAGE_VERSION ${GIT_DESCRIBE_STRING})
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}/package")
include(CPack)
+2 -2
View File
@@ -1,6 +1,6 @@
# libloot
[![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/48a540m7ywuqcl3b/branch/master?svg=true)](https://ci.appveyor.com/project/LOOT/libloot/branch/master)
![CI](https://github.com/loot/libloot/workflows/CI/badge.svg?branch=master&event=push)
[![Travis Build Status](https://travis-ci.org/loot/libloot.svg?branch=master)](https://travis-ci.org/loot/libloot)
[![Documentation Status](https://readthedocs.org/projects/loot-api/badge/?version=latest)](http://loot-api.readthedocs.io/en/latest/?badge=latest)
@@ -24,7 +24,7 @@ libloot-<last tag>-<revisions since tag>-g<short revision ID>_<branch>-<platform
### Windows
Refer to `appveyor.yml` for the build process.
Refer to `.github/workflows/release.yml` for the build process.
### Linux
-106
View File
@@ -1,106 +0,0 @@
os: Visual Studio 2017
version: "{build}-{branch}"
configuration: RelWithDebInfo
platform:
- Win32
- x64
matrix:
fast_finish: true
environment:
PATH: C:\Users\appveyor\.cargo\bin;$(APPVEYOR_BUILD_FOLDER)\Doxygen.1.8.14\tools;$(PATH)
github_auth_token:
secure: yDqT5l/e5MntbW99V6+MHlfFgNv+UIogFfeyUVqtFk5lFRB/dAraLLwKCLl6y+DH
bintray_auth_token:
secure: PgsEA6TjHVf718zMnK7J/fT1hUAVNKBeWhpYgYaeCyeZk37VT4Ics6j7+B7ElLEr
cache:
- C:\Users\appveyor\.cargo\bin\cbindgen.exe
- C:\Users\appveyor\.cargo\.crates.toml
- C:\Users\appveyor\.cargo\.crates2.json
install:
- curl -sSf -o rustup-init.exe https://win.rustup.rs/x86_64
- rustup-init.exe -y
- rustup target add i686-pc-windows-msvc
- cargo install cbindgen --version 0.13.2
- nuget install doxygen -Version 1.8.14
- py -3.7 -m pip install -r docs/requirements.txt
- ps: (New-Object Net.WebClient).DownloadFile('https://raw.githubusercontent.com/Ortham/ci-scripts/2.1.3/delete_old_bintray_versions.py', "$env:APPVEYOR_BUILD_FOLDER\delete_old_bintray_versions.py")
- ps: if ($env:PLATFORM -eq "Win32") { $env:ADDRESS_MODEL = '32' } else { $env:ADDRESS_MODEL = '64' }
before_build:
- cd %APPVEYOR_BUILD_FOLDER%
- ps: mkdir build
- cd build
- ps: |
if ($env:PLATFORM -eq 'Win32') {
cmake .. -G "Visual Studio 15 2017" -DBOOST_ROOT="C:\Libraries\boost_1_67_0" -DBOOST_LIBRARYDIR="C:\Libraries\boost_1_67_0\lib32-msvc-14.1"
} else {
cmake .. -G "Visual Studio 15 2017 Win64" -DBOOST_ROOT="C:\Libraries\boost_1_67_0" -DBOOST_LIBRARYDIR="C:\Libraries\boost_1_67_0\lib64-msvc-14.1"
}
build:
verbosity: minimal
project: '$(APPVEYOR_BUILD_FOLDER)\build\libloot.sln'
test_script:
- cd %APPVEYOR_BUILD_FOLDER%\build\%CONFIGURATION%
# Some tests call Git, so set a user
- git config --global user.email "appveyor@ci"
- git config --global user.name "AppVeyor"
- libloot_internals_tests.exe --gtest_output=xml:libloot_internals_tests.xml
- libloot_tests.exe --gtest_output=xml:libloot_tests.xml
after_test:
- cd %APPVEYOR_BUILD_FOLDER%
- C:\Python37-x64\Scripts\sphinx-build -b html docs build\docs\html
- ps: $env:GIT_DESCRIBE = ((git describe --tags --long --always --abbrev=7) | Out-String) -replace "`n|`r", ""
- cd build
- cpack -C %CONFIGURATION%
artifacts:
- path: build\package\libloot-$(GIT_DESCRIBE)_$(APPVEYOR_REPO_BRANCH)-win$(ADDRESS_MODEL).7z
name: API
deploy:
- provider: BinTray
username: wrinklyninja
api_key:
secure: PgsEA6TjHVf718zMnK7J/fT1hUAVNKBeWhpYgYaeCyeZk37VT4Ics6j7+B7ElLEr
subject: loot
repo: snapshots
package: libloot
version: $(GIT_DESCRIBE)_$(APPVEYOR_REPO_BRANCH)
publish: true
artifact: API
- provider: GitHub
tag: $(APPVEYOR_REPO_TAG_NAME)
release: libloot v$(APPVEYOR_REPO_TAG_NAME)
description: |
Requires Windows 7 or later and the [MSVC 2017 x86 redistributable](https://download.visualstudio.microsoft.com/download/pr/749aa419-f9e4-4578-a417-a43786af205e/d59197078cc425377be301faba7dd87a/vc_redist.x86.exe), and [7-Zip](http://www.7-zip.org/) to extract the archives.
## Change Logs
- [API](https://loot-api.readthedocs.io/en/$(APPVEYOR_REPO_TAG_NAME)/api/changelog.html)
- [Metadata Syntax](https://loot-api.readthedocs.io/en/$(APPVEYOR_REPO_TAG_NAME)/metadata/changelog.html)
*Note: The files below with `tar.xz` extensions contain Linux binaries. They won't work on Windows computers.*
auth_token:
secure: yDqT5l/e5MntbW99V6+MHlfFgNv+UIogFfeyUVqtFk5lFRB/dAraLLwKCLl6y+DH
artifact: API
draft: false
force_update: true
on:
appveyor_repo_tag: true
on_success:
- ps: py -3 "$env:APPVEYOR_BUILD_FOLDER\delete_old_bintray_versions.py" -g loot/libloot -b loot/snapshots/libloot -u wrinklyninja -k $env:bintray_auth_token -t $env:github_auth_token -n 30
on_finish:
- ps: (New-Object System.Net.WebClient).UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", "$($env:APPVEYOR_BUILD_FOLDER)\build\$($env:CONFIGURATION)\libloot_internals_tests.xml")
- ps: (New-Object System.Net.WebClient).UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", "$($env:APPVEYOR_BUILD_FOLDER)\build\$($env:CONFIGURATION)\libloot_tests.xml")
@@ -40,11 +40,12 @@ protected:
gamePathSymlink(dataPath.parent_path().string() + ".symlink"),
localPathSymlink(localPath.string() + ".symlink"),
gamePathJunctionLink(dataPath.parent_path().string() + ".junction"),
localPathJunctionLink(localPath.string() + ".junction") {}
localPathJunctionLink(localPath.string() + ".junction"),
originalWorkingDirectory(std::filesystem::current_path()) {}
void SetUp() {
using std::filesystem::status;
using std::filesystem::file_type;
using std::filesystem::status;
CommonGameTestFixture::SetUp();
std::filesystem::create_directory_symlink(dataPath.parent_path(),
@@ -56,8 +57,7 @@ protected:
#ifdef _WIN32
system(("mklink /J \"" +
std::filesystem::absolute(gamePathJunctionLink).string() +
"\" \"" +
std::filesystem::absolute(gamePathJunctionLink).string() + "\" \"" +
std::filesystem::absolute(dataPath).parent_path().string() + "\"")
.c_str());
system(("mklink /J \"" +
@@ -65,14 +65,21 @@ protected:
"\" \"" + std::filesystem::absolute(localPath).string() + "\"")
.c_str());
#endif
// relative() doesn't work when the current working directory and the given
// path are on separate drives, so ensure that's not the case.
std::filesystem::current_path(dataPath.parent_path().parent_path());
}
void TearDown() { std::filesystem::current_path(originalWorkingDirectory); }
std::shared_ptr<GameInterface> handle_;
const std::filesystem::path gamePathSymlink;
const std::filesystem::path localPathSymlink;
const std::filesystem::path gamePathJunctionLink;
const std::filesystem::path localPathJunctionLink;
const std::filesystem::path originalWorkingDirectory;
};
// Pass an empty first argument, as it's a prefix for the test instantation,
@@ -97,46 +104,41 @@ TEST_P(CreateGameHandleTest,
TEST_P(CreateGameHandleTest,
shouldSucceedIfPassedValidParametersWithAbsolutePaths) {
EXPECT_NO_THROW(handle_ = CreateGameHandle(GetParam(),
dataPath.parent_path(),
localPath));
EXPECT_NO_THROW(handle_ = CreateGameHandle(
GetParam(), dataPath.parent_path(), localPath));
EXPECT_TRUE(handle_);
}
TEST_P(CreateGameHandleTest, shouldThrowIfPassedAGamePathThatDoesNotExist) {
EXPECT_THROW(
CreateGameHandle(GetParam(), missingPath, localPath),
std::invalid_argument);
EXPECT_THROW(CreateGameHandle(GetParam(), missingPath, localPath),
std::invalid_argument);
}
TEST_P(CreateGameHandleTest, shouldThrowIfPassedALocalPathThatDoesNotExist) {
EXPECT_THROW(
CreateGameHandle(
GetParam(), dataPath.parent_path(), missingPath),
CreateGameHandle(GetParam(), dataPath.parent_path(), missingPath),
std::invalid_argument);
}
#ifdef _WIN32
TEST_P(CreateGameHandleTest, shouldReturnOkIfPassedAnEmptyLocalPathString) {
EXPECT_NO_THROW(handle_ = CreateGameHandle(
GetParam(), dataPath.parent_path(), ""));
EXPECT_NO_THROW(handle_ =
CreateGameHandle(GetParam(), dataPath.parent_path(), ""));
EXPECT_TRUE(handle_);
}
#endif
TEST_P(CreateGameHandleTest, shouldReturnOkIfPassedGameAndLocalPathSymlinks) {
EXPECT_NO_THROW(handle_ = CreateGameHandle(GetParam(),
gamePathSymlink,
localPathSymlink));
EXPECT_NO_THROW(handle_ = CreateGameHandle(
GetParam(), gamePathSymlink, localPathSymlink));
EXPECT_TRUE(handle_);
}
#ifdef _WIN32
TEST_P(CreateGameHandleTest,
shouldReturnOkIfPassedGameAndLocalPathJunctionLinks) {
EXPECT_NO_THROW(handle_ = CreateGameHandle(GetParam(),
gamePathJunctionLink,
localPathJunctionLink));
EXPECT_NO_THROW(handle_ = CreateGameHandle(
GetParam(), gamePathJunctionLink, localPathJunctionLink));
EXPECT_TRUE(handle_);
}
#endif