From 509a39212d518cb472d7ff93066feb7ac2bd9883 Mon Sep 17 00:00:00 2001 From: Jeremy Hayes Date: Fri, 17 Sep 2021 14:06:48 -0600 Subject: [PATCH] Migrate travis to github actions --- .github/workflows/continuous_deployment.yml | 168 +++++++++++++++++++ .github/workflows/continuous_integration.yml | 157 +++++++++++++++++ .github/workflows/deploy.js | 73 ++++++++ .travis.yml | 141 ---------------- README.md | 5 +- license-checker.cfg | 2 + 6 files changed, 403 insertions(+), 143 deletions(-) create mode 100644 .github/workflows/continuous_deployment.yml create mode 100644 .github/workflows/continuous_integration.yml create mode 100644 .github/workflows/deploy.js delete mode 100644 .travis.yml diff --git a/.github/workflows/continuous_deployment.yml b/.github/workflows/continuous_deployment.yml new file mode 100644 index 00000000..86f439db --- /dev/null +++ b/.github/workflows/continuous_deployment.yml @@ -0,0 +1,168 @@ +# NOTE: This workflow was ported from Travis. +# Travis was using Ubuntu 14.04. Ubuntu 14.04 is not supportted by GitHub workflows. Ubuntu 20.04 is recommended. +# Travis was using Clang 3.6. The earliest version support by Ubuntu 20.04 is Clang 6.0. +# Travis was caching the clang package. APT package caching is not natively supported by GitHub actions/cache. +# Travis was using Mac OS X 10.13.6 / Xcode 9.4.1 / LLVM 9.1.0 + +# NOTE: The following documentation may be useful to maintainers of this workflow. +# Github actions: https://docs.github.com/en/actions +# Github github-script action: https://github.com/actions/github-script +# GitHub REST API: https://docs.github.com/en/rest +# Octokit front-end to the GitHub REST API: https://octokit.github.io/rest.js/v18 +# Octokit endpoint methods: https://github.com/octokit/plugin-rest-endpoint-methods.js/tree/master/docs/repos + +# TODO: Use actions/upload-artifact and actions/download-artifact to simplify deployment. +# TODO: Use composite actions to refactor redundant code. + +name: Continuous Deployment + +on: + workflow_dispatch: + push: + branches: + - master + +jobs: + linux: + runs-on: ${{matrix.os.genus}} + strategy: + fail-fast: false + matrix: + os: [{genus: ubuntu-20.04, family: linux}] + compiler: [{cc: clang, cxx: clang++}, {cc: gcc, cxx: g++}] + cmake_build_type: [Debug, Release] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: '3.7' + - name: Install Ubuntu Package Dependencies + run: | + sudo apt-get -qq update + sudo apt-get install -y clang-6.0 + - name: Install GoogleTest + run: | + # check out pre-breakage version of googletest; can be deleted when + # issue 3128 is fixed + # git clone --depth=1 https://github.com/google/googletest.git External/googletest + mkdir -p External/googletest + cd External/googletest + git init + git remote add origin https://github.com/google/googletest.git + git fetch --depth 1 origin 0c400f67fcf305869c5fb113dd296eca266c9725 + git reset --hard FETCH_HEAD + cd ../.. + - name: Update Glslang Sources + run: | + ./update_glslang_sources.py + - name: Build + env: + CC: ${{matrix.compiler.cc}} + CXX: ${{matrix.compiler.cxx}} + run: | + mkdir build && cd build + cmake -DCMAKE_BUILD_TYPE=${{matrix.cmake_build_type}} -DCMAKE_INSTALL_PREFIX=`pwd`/install .. + make -j4 install + - name: Test + run: | + cd build + ctest --output-on-failure && + cd ../Test && ./runtests + - name: Zip + if: ${{ matrix.compiler.cc == 'clang' }} + env: + ARCHIVE: glslang-master-${{matrix.os.family}}-${{matrix.cmake_build_type}}.zip + run: | + cd build/install + zip ${ARCHIVE} \ + bin/glslangValidator \ + include/glslang/* \ + lib/libGenericCodeGen${SUFFIX}.a \ + lib/libglslang${SUFFIX}.a \ + lib/libglslang-default-resource-limits${SUFFIX}.a \ + lib/libHLSL${SUFFIX}.a \ + lib/libMachineIndependent${SUFFIX}.a \ + lib/libOGLCompiler${SUFFIX}.a \ + lib/libOSDependent${SUFFIX}.a \ + lib/libSPIRV${SUFFIX}.a \ + lib/libSPVRemapper${SUFFIX}.a \ + lib/libSPIRV-Tools${SUFFIX}.a \ + lib/libSPIRV-Tools-opt${SUFFIX}.a + - name: Deploy + if: ${{ matrix.compiler.cc == 'clang' }} + env: + ARCHIVE: glslang-master-${{matrix.os.family}}-${{matrix.cmake_build_type}}.zip + uses: actions/github-script@v5 + with: + script: | + const script = require('.github/workflows/deploy.js') + await script({github, context, core}) + + macos: + runs-on: ${{matrix.os.genus}} + strategy: + fail-fast: false + matrix: + os: [{genus: macos-10.15, family: osx}] + compiler: [{cc: clang, cxx: clang++}] + cmake_build_type: [Debug, Release] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: '3.7' + - name: Install GoogleTest + run: | + # check out pre-breakage version of googletest; can be deleted when + # issue 3128 is fixed + # git clone --depth=1 https://github.com/google/googletest.git External/googletest + mkdir -p External/googletest + cd External/googletest + git init + git remote add origin https://github.com/google/googletest.git + git fetch --depth 1 origin 0c400f67fcf305869c5fb113dd296eca266c9725 + git reset --hard FETCH_HEAD + cd ../.. + - name: Update Glslang Sources + run: | + ./update_glslang_sources.py + - name: Build + env: + CC: ${{matrix.compiler.cc}} + CXX: ${{matrix.compiler.cxx}} + run: | + mkdir build && cd build + cmake -DCMAKE_BUILD_TYPE=${{matrix.cmake_build_type}} -DCMAKE_INSTALL_PREFIX=`pwd`/install .. + make -j4 install + - name: Test + run: | + cd build + ctest --output-on-failure && + cd ../Test && ./runtests + - name: Zip + env: + ARCHIVE: glslang-master-${{matrix.os.family}}-${{matrix.cmake_build_type}}.zip + run: | + cd build/install + zip ${ARCHIVE} \ + bin/glslangValidator \ + include/glslang/* \ + lib/libGenericCodeGen${SUFFIX}.a \ + lib/libglslang${SUFFIX}.a \ + lib/libglslang-default-resource-limits${SUFFIX}.a \ + lib/libHLSL${SUFFIX}.a \ + lib/libMachineIndependent${SUFFIX}.a \ + lib/libOGLCompiler${SUFFIX}.a \ + lib/libOSDependent${SUFFIX}.a \ + lib/libSPIRV${SUFFIX}.a \ + lib/libSPVRemapper${SUFFIX}.a \ + lib/libSPIRV-Tools${SUFFIX}.a \ + lib/libSPIRV-Tools-opt${SUFFIX}.a + - name: Deploy + env: + ARCHIVE: glslang-master-${{matrix.os.family}}-${{matrix.cmake_build_type}}.zip + uses: actions/github-script@v5 + with: + script: | + const script = require('.github/workflows/deploy.js') + await script({github, context, core}) diff --git a/.github/workflows/continuous_integration.yml b/.github/workflows/continuous_integration.yml new file mode 100644 index 00000000..feec0dc2 --- /dev/null +++ b/.github/workflows/continuous_integration.yml @@ -0,0 +1,157 @@ +# NOTE: This workflow was ported from Travis. +# Travis was using Ubuntu 14.04. Ubuntu 14.04 is not supportted by GitHub workflows. Ubuntu 20.04 is recommended. +# Travis was using Clang 3.6. The earliest version support by Ubuntu 20.04 is Clang 6.0. +# Travis was caching the clang package. APT package caching is not natively supported by GitHub actions/cache. +# Travis was using Mac OS X 10.13.6 / Xcode 9.4.1 / LLVM 9.1.0 +# +name: Continuous Integration + +on: + workflow_dispatch: + pull_request: + branches: + - master + +jobs: + linux: + runs-on: ${{matrix.os}} + strategy: + fail-fast: false + matrix: + os: [ubuntu-20.04] + compiler: [{cc: clang, cxx: clang++}, {cc: gcc, cxx: g++}] + cmake_build_type: [Debug, Release] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: '3.7' + - name: Install Ubuntu Package Dependencies + run: | + sudo apt-get -qq update + sudo apt-get install -y clang-6.0 + - name: Install GoogleTest + run: | + # check out pre-breakage version of googletest; can be deleted when + # issue 3128 is fixed + # git clone --depth=1 https://github.com/google/googletest.git External/googletest + mkdir -p External/googletest + cd External/googletest + git init + git remote add origin https://github.com/google/googletest.git + git fetch --depth 1 origin 0c400f67fcf305869c5fb113dd296eca266c9725 + git reset --hard FETCH_HEAD + cd ../.. + - name: Update Glslang Sources + run: | + ./update_glslang_sources.py + - name: Build + env: + CC: ${{matrix.compiler.cc}} + CXX: ${{matrix.compiler.cxx}} + run: | + mkdir build && cd build + cmake -DCMAKE_BUILD_TYPE=${{matrix.cmake_build_type}} -DCMAKE_INSTALL_PREFIX=`pwd`/install .. + make -j4 install + - name: Test + run: | + cd build + ctest --output-on-failure && + cd ../Test && ./runtests + + macos: + runs-on: ${{matrix.os}} + strategy: + fail-fast: false + matrix: + os: [macos-10.15] + compiler: [{cc: clang, cxx: clang++}] + cmake_build_type: [Debug, Release] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: '3.7' + - name: Install GoogleTest + run: | + # check out pre-breakage version of googletest; can be deleted when + # issue 3128 is fixed + # git clone --depth=1 https://github.com/google/googletest.git External/googletest + mkdir -p External/googletest + cd External/googletest + git init + git remote add origin https://github.com/google/googletest.git + git fetch --depth 1 origin 0c400f67fcf305869c5fb113dd296eca266c9725 + git reset --hard FETCH_HEAD + cd ../.. + - name: Update Glslang Sources + run: | + ./update_glslang_sources.py + - name: Build + env: + CC: ${{matrix.compiler.cc}} + CXX: ${{matrix.compiler.cxx}} + run: | + mkdir build && cd build + cmake -DCMAKE_BUILD_TYPE=${{matrix.cmake_build_type}} -DCMAKE_INSTALL_PREFIX=`pwd`/install .. + make -j4 install + - name: Test + run: | + cd build + ctest --output-on-failure && + cd ../Test && ./runtests + + android: + runs-on: ${{matrix.os}} + strategy: + fail-fast: false + matrix: + os: [ubuntu-20.04] + compiler: [{cc: clang, cxx: clang++}] + cmake_build_type: [Release] + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: '3.7' + - name: Install Ubuntu Package Dependencies + if: ${{matrix.os == 'ubuntu-20.04'}} + run: | + sudo apt-get -qq update + sudo apt-get install -y clang-6.0 + - name: Install Android NDK + run: | + export ANDROID_NDK=$HOME/android-ndk + git init $ANDROID_NDK + pushd $ANDROID_NDK + git remote add dneto0 https://github.com/dneto0/android-ndk.git + git fetch --depth=1 dneto0 r17b-strip + git checkout FETCH_HEAD + popd + - name: Install GoogleTest + run: | + # check out pre-breakage version of googletest; can be deleted when + # issue 3128 is fixed + # git clone --depth=1 https://github.com/google/googletest.git External/googletest + mkdir -p External/googletest + cd External/googletest + git init + git remote add origin https://github.com/google/googletest.git + git fetch --depth 1 origin 0c400f67fcf305869c5fb113dd296eca266c9725 + git reset --hard FETCH_HEAD + cd ../.. + - name: Update Glslang Sources + run: | + ./update_glslang_sources.py + - name: Build + env: + CC: ${{matrix.compiler.cc}} + CXX: ${{matrix.compiler.cxx}} + run: | + export ANDROID_NDK=$HOME/android-ndk + export TOOLCHAIN_PATH=$ANDROID_NDK/build/cmake/android.toolchain.cmake + echo $ANDROID_NDK + echo $TOOLCHAIN_PATH + mkdir build && cd build + cmake -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_PATH} -DANDROID_NATIVE_API_LEVEL=android-14 -DCMAKE_BUILD_TYPE=${{matrix.cmake_build_type}} -DANDROID_ABI="armeabi-v7a with NEON" -DBUILD_TESTING=OFF .. + make -j4 diff --git a/.github/workflows/deploy.js b/.github/workflows/deploy.js new file mode 100644 index 00000000..82ebb1bd --- /dev/null +++ b/.github/workflows/deploy.js @@ -0,0 +1,73 @@ +module.exports = async ({github, context, core}) => { + try { + await github.rest.git.updateRef({ + owner: context.repo.owner, + repo: context.repo.repo, + ref: 'tags/master-tot', + sha: context.sha + }) + } catch (error) { + core.setFailed(`upload master-tot tag; ${error.name}; ${error.message}`) + } + + let release + try { + release = await github.rest.repos.getReleaseByTag({ + owner: context.repo.owner, + repo: context.repo.repo, + tag: 'master-tot' + }) + } catch (error) { + core.setFailed(`get the master release; ${error.name}; ${error.message}`) + } + + try { + await github.rest.repos.updateRelease({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: release.data.id + }) + } catch (error) { + core.setFailed(`update the master release; ${error.name}; ${error.message}`) + } + + let release_assets + try { + release_assets = await github.rest.repos.listReleaseAssets({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: release.data.id + }) + } catch (error) { + core.setFailed(`list release assets; ${error.name}; ${error.message}`) + } + + const { ARCHIVE } = process.env + for (const release_asset of release_assets.data) { + if (release_asset.name === `${ ARCHIVE }`) { + try { + await github.rest.repos.deleteReleaseAsset({ + owner: context.repo.owner, + repo: context.repo.repo, + asset_id: release_asset.id + }) + } catch (error) { + core.setFailed(`delete ${ ARCHIVE }; ${error.name}; ${error.message}`) + } + } + } + + try { + const asset_path = `./build/install/${ ARCHIVE }` + const fs = require("fs") + await github.rest.repos.uploadReleaseAsset({ + owner: context.repo.owner, + repo: context.repo.repo, + release_id: release.data.id, + name: `${ ARCHIVE }`, + data: fs.readFileSync(asset_path) + }) + } catch (error) { + core.setFailed(`upload ${ ARCHIVE }; ${error.name}; ${error.message}`) + } +} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index cb0392ef..00000000 --- a/.travis.yml +++ /dev/null @@ -1,141 +0,0 @@ -# Linux and Mac Build Configuration for Travis - -language: cpp - -os: - - linux - - osx - -# Use Ubuntu 14.04 LTS (Trusty) as the Linux testing environment. -sudo: false -dist: trusty - -env: - global: - - secure: aGFrgzyKp+84hKrGkxVWg8cHV61uqrKEHT38gfSQK6+WS4GfLOyH83p7WnsEBb7AMhzU7LMNFdvOFr6+NaMpVnqRvc40CEG1Q+lNg9Pq9mhIZLowvDrfqTL9kQ+8Nbw5Q6/dg6CTvY7fvRfpfCEmKIUZBRkoKUuHeuM1uy3IupFcdNuL5bSYn3Beo+apSJginh9DI4BLDXFUgBzTRSLLyCX5g3cpaeGGOCr8quJlYx75W6HRck5g9SZuLtUoH9GFEV3l+ZEWB8noErW+J56L03bwNwFuuAh321evw++oQk5KFa8rlDvar3SJ3b1RHB8u/eq5DBYMyaK/fS8+Q7QbGr8diF/wDe68bKO7U9IhpNfExXmczCpExjHomW5TQv4rYdGhygPMfW97aIsPRYyNKcl4fkmb7NDrM8w0Jscdq2g5c2Kz0ItyZoBri/NXLwFQQjaVCs7Pf97TjuMA7mK0GJmDTRzi6SrDYlWMt5BQL3y0CCojyfLIRcTh0CQjQI29s97bLfQrYAxt9GNNFR+HTXRLLrkaAlJkPGEPwUywlSfEThnvHLesNxYqemolAYpQT4ithoL4GehGIHmaxsW295aKVhuRf8K9eBODNqrfblvM42UHhjntT+92ZnQ/Gkq80GqaMxnxi4PO5FyPIxt0r981b54YBkWi8YA4P7w5pNI= - matrix: - - GLSLANG_BUILD_TYPE=Release - - GLSLANG_BUILD_TYPE=Debug - -compiler: - - clang - - gcc - -matrix: - fast_finish: true # Show final status immediately if a test fails. - exclude: - # Skip GCC builds on Mac OS X. - - os: osx - compiler: gcc - include: - # Additional build using Android NDK. - - env: BUILD_NDK=ON - -cache: - apt: true - -branches: - only: - - master - -addons: - apt: - packages: - - clang-3.6 - -install: - # Make sure that clang-3.6 is selected on Linux. - - if [[ "$TRAVIS_OS_NAME" == "linux" && "$CC" == "clang" ]]; then - export CC=clang-3.6 CXX=clang++-3.6; - fi - # Download a recent Android NDK and use its android.toolchain.cmake file. - - if [[ "$BUILD_NDK" == "ON" ]]; then - export ANDROID_NDK=$HOME/android-ndk; - git init $ANDROID_NDK; - pushd $ANDROID_NDK; - git remote add dneto0 https://github.com/dneto0/android-ndk.git; - git fetch --depth=1 dneto0 r17b-strip; - git checkout FETCH_HEAD; - popd; - export TOOLCHAIN_PATH=$ANDROID_NDK/build/cmake/android.toolchain.cmake; - fi - -before_script: - # check out pre-breakage version of googletest; can be deleted when - # issue 3128 is fixed - # git clone --depth=1 https://github.com/google/googletest.git External/googletest - - mkdir -p External/googletest - - cd External/googletest - - git init - - git remote add origin https://github.com/google/googletest.git - - git fetch --depth 1 origin 0c400f67fcf305869c5fb113dd296eca266c9725 - - git reset --hard FETCH_HEAD - - cd ../.. - # get spirv-tools and spirv-headers - - ./update_glslang_sources.py - -script: - - mkdir build && cd build - # For Android, do release building using NDK without testing. - # Use android-14, the oldest native API level supporeted by NDK r17b. - # We can use newer API levels if we want. - # For Linux and macOS, do debug/release building with testing. - - if [[ "$BUILD_NDK" == "ON" ]]; then - cmake -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_PATH} - -DANDROID_NATIVE_API_LEVEL=android-14 - -DCMAKE_BUILD_TYPE=Release - -DANDROID_ABI="armeabi-v7a with NEON" - -DBUILD_TESTING=OFF ..; - make -j4; - else - cmake -DCMAKE_BUILD_TYPE=${GLSLANG_BUILD_TYPE} - -DCMAKE_INSTALL_PREFIX=`pwd`/install ..; - make -j4 install; - ctest --output-on-failure && - cd ../Test && ./runtests; - fi - -after_success: - # For debug build, the generated dll has a postfix "d" in its name. - - if [[ "${GLSLANG_BUILD_TYPE}" == "Debug" ]]; then - export SUFFIX="d"; - else - export SUFFIX=""; - fi - # Create tarball for deployment - - if [[ ${CC} == clang* && "${BUILD_NDK}" != "ON" ]]; then - cd ../build/install; - export TARBALL=glslang-master-${TRAVIS_OS_NAME}-${GLSLANG_BUILD_TYPE}.zip; - zip ${TARBALL} - bin/glslangValidator - include/glslang/* - lib/libGenericCodeGen${SUFFIX}.a - lib/libglslang${SUFFIX}.a - lib/libglslang-default-resource-limits${SUFFIX}.a - lib/libHLSL${SUFFIX}.a - lib/libMachineIndependent${SUFFIX}.a - lib/libOGLCompiler${SUFFIX}.a - lib/libOSDependent${SUFFIX}.a - lib/libSPIRV${SUFFIX}.a - lib/libSPVRemapper${SUFFIX}.a - lib/libSPIRV-Tools${SUFFIX}.a - lib/libSPIRV-Tools-opt${SUFFIX}.a; - fi - -before_deploy: - # Tag the current top of the tree as "master-tot". - # Travis CI replies on the tag name to properly push to GitHub Releases. - - git config --global user.name "Travis CI" - - git config --global user.email "builds@travis-ci.org" - - git tag -f master-tot - - git push -q -f https://${glslangtoken}@github.com/KhronosGroup/glslang --tags - -deploy: - provider: releases - api_key: ${glslangtoken} - on: - branch: master - condition: ${CC} == clang* && ${BUILD_NDK} != ON - file: ${TARBALL} - skip_cleanup: true - overwrite: true diff --git a/README.md b/README.md index 9b8cfb3f..9a5ef3b8 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,9 @@ See issue #1964. If people are only using this location to get spirv.hpp, I recommend they get that from [SPIRV-Headers](https://github.com/KhronosGroup/SPIRV-Headers) instead. -[![Build Status](https://travis-ci.org/KhronosGroup/glslang.svg?branch=master)](https://travis-ci.org/KhronosGroup/glslang) -[![Build status](https://ci.appveyor.com/api/projects/status/q6fi9cb0qnhkla68/branch/master?svg=true)](https://ci.appveyor.com/project/Khronoswebmaster/glslang/branch/master) +[![appveyor status](https://ci.appveyor.com/api/projects/status/q6fi9cb0qnhkla68/branch/master?svg=true)](https://ci.appveyor.com/project/Khronoswebmaster/glslang/branch/master) +![Continuous Integration](https://github.com/KhronosGroup/glslang/actions/workflows/continuous_integration.yml/badge.svg) +![Continuous Deployment](https://github.com/KhronosGroup/glslang/actions/workflows/continuous_deployment.yml/badge.svg) # Glslang Components and Status diff --git a/license-checker.cfg b/license-checker.cfg index 409f18ef..51ce2762 100644 --- a/license-checker.cfg +++ b/license-checker.cfg @@ -15,6 +15,8 @@ "_config.yml", ".*", + ".github/workflows/*.yml", + ".github/workflows/*.js", "CMakeSettings.json", "known_good_khr.json", "known_good.json",