From 5c2dd2167d26d985cc1e35b5f3139f924b54595f Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sun, 9 Aug 2020 14:03:01 +0100 Subject: [PATCH] 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. --- .github/workflows/ci.yml | 121 ++++++++++++++++ .github/workflows/release.yml | 131 ++++++++++++++++++ .travis.yml | 11 +- CMakeLists.txt | 27 ++-- README.md | 4 +- appveyor.yml | 106 -------------- .../api/interface/create_game_handle_test.h | 42 +++--- 7 files changed, 293 insertions(+), 149 deletions(-) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/release.yml delete mode 100644 appveyor.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..57de0374 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..2e455186 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 diff --git a/.travis.yml b/.travis.yml index c4d99bd7..b2f163af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ef80413..32cf73d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/README.md b/README.md index aa3b6a34..18356f3b 100644 --- a/README.md +++ b/README.md @@ -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---g_- 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