1617a3babSopenharmony_ci# NOTE: This workflow was ported from Travis.
2617a3babSopenharmony_ci# Travis was using Ubuntu 14.04. Ubuntu 14.04 is not supportted by GitHub workflows. Ubuntu 20.04 is recommended.
3617a3babSopenharmony_ci# Travis was using Clang 3.6. The earliest version support by Ubuntu 20.04 is Clang 6.0.
4617a3babSopenharmony_ci# Travis was caching the clang package. APT package caching is not natively supported by GitHub actions/cache.
5617a3babSopenharmony_ci# Travis was using Mac OS X 10.13.6 / Xcode 9.4.1 / LLVM 9.1.0
6617a3babSopenharmony_ci
7617a3babSopenharmony_ci# NOTE: The following documentation may be useful to maintainers of this workflow.
8617a3babSopenharmony_ci# Github actions: https://docs.github.com/en/actions
9617a3babSopenharmony_ci# Github github-script action: https://github.com/actions/github-script
10617a3babSopenharmony_ci# GitHub REST API: https://docs.github.com/en/rest
11617a3babSopenharmony_ci# Octokit front-end to the GitHub REST API: https://octokit.github.io/rest.js/v18
12617a3babSopenharmony_ci# Octokit endpoint methods: https://github.com/octokit/plugin-rest-endpoint-methods.js/tree/master/docs/repos
13617a3babSopenharmony_ci
14617a3babSopenharmony_ci# TODO: Use actions/upload-artifact and actions/download-artifact to simplify deployment.
15617a3babSopenharmony_ci# TODO: Use composite actions to refactor redundant code.
16617a3babSopenharmony_ci
17617a3babSopenharmony_ciname: Continuous Deployment
18617a3babSopenharmony_ci
19617a3babSopenharmony_cion:
20617a3babSopenharmony_ci    workflow_dispatch:
21617a3babSopenharmony_ci    push:
22617a3babSopenharmony_ci        branches:
23617a3babSopenharmony_ci            - master
24617a3babSopenharmony_ci
25617a3babSopenharmony_cijobs:
26617a3babSopenharmony_ci    linux:
27617a3babSopenharmony_ci        runs-on: ${{matrix.os.genus}}
28617a3babSopenharmony_ci        strategy:
29617a3babSopenharmony_ci            fail-fast: false
30617a3babSopenharmony_ci            matrix:
31617a3babSopenharmony_ci                os: [{genus: ubuntu-20.04, family: linux}]
32617a3babSopenharmony_ci                compiler: [{cc: clang, cxx: clang++}, {cc: gcc, cxx: g++}]
33617a3babSopenharmony_ci                cmake_build_type: [Debug, Release]
34617a3babSopenharmony_ci        steps:
35617a3babSopenharmony_ci            - uses: actions/checkout@v2
36617a3babSopenharmony_ci            - uses: actions/setup-python@v2
37617a3babSopenharmony_ci              with:
38617a3babSopenharmony_ci                  python-version: '3.7'
39617a3babSopenharmony_ci            - name: Install Ubuntu Package Dependencies
40617a3babSopenharmony_ci              run: |
41617a3babSopenharmony_ci                  sudo apt-get -qq update
42617a3babSopenharmony_ci                  sudo apt-get install -y clang-6.0
43617a3babSopenharmony_ci            - name: Install GoogleTest
44617a3babSopenharmony_ci              run: |
45617a3babSopenharmony_ci                  # check out pre-breakage version of googletest; can be deleted when
46617a3babSopenharmony_ci                  # issue 3128 is fixed
47617a3babSopenharmony_ci                  # git clone --depth=1 https://github.com/google/googletest.git External/googletest
48617a3babSopenharmony_ci                  mkdir -p External/googletest
49617a3babSopenharmony_ci                  cd External/googletest
50617a3babSopenharmony_ci                  git init
51617a3babSopenharmony_ci                  git remote add origin https://github.com/google/googletest.git
52617a3babSopenharmony_ci                  git fetch --depth 1 origin 0c400f67fcf305869c5fb113dd296eca266c9725
53617a3babSopenharmony_ci                  git reset --hard FETCH_HEAD
54617a3babSopenharmony_ci                  cd ../..
55617a3babSopenharmony_ci            - name: Update Glslang Sources
56617a3babSopenharmony_ci              run: |
57617a3babSopenharmony_ci                  ./update_glslang_sources.py
58617a3babSopenharmony_ci            - name: Build
59617a3babSopenharmony_ci              env:
60617a3babSopenharmony_ci                  CC: ${{matrix.compiler.cc}}
61617a3babSopenharmony_ci                  CXX: ${{matrix.compiler.cxx}}
62617a3babSopenharmony_ci              run: |
63617a3babSopenharmony_ci                  mkdir build && cd build
64617a3babSopenharmony_ci                  cmake -DCMAKE_BUILD_TYPE=${{matrix.cmake_build_type}} -DCMAKE_INSTALL_PREFIX=`pwd`/install ..
65617a3babSopenharmony_ci                  make -j4 install
66617a3babSopenharmony_ci            - name: Test
67617a3babSopenharmony_ci              run: |
68617a3babSopenharmony_ci                  cd build
69617a3babSopenharmony_ci                  ctest --output-on-failure &&
70617a3babSopenharmony_ci                  cd ../Test && ./runtests
71617a3babSopenharmony_ci            - name: Zip
72617a3babSopenharmony_ci              if: ${{ matrix.compiler.cc == 'clang' }}
73617a3babSopenharmony_ci              env:
74617a3babSopenharmony_ci                  ARCHIVE: glslang-master-${{matrix.os.family}}-${{matrix.cmake_build_type}}.zip
75617a3babSopenharmony_ci              run: |
76617a3babSopenharmony_ci                  cd build/install
77617a3babSopenharmony_ci                  zip ${ARCHIVE} \
78617a3babSopenharmony_ci                      bin/glslangValidator \
79617a3babSopenharmony_ci                      include/glslang/* \
80617a3babSopenharmony_ci                      lib/libGenericCodeGen${SUFFIX}.a \
81617a3babSopenharmony_ci                      lib/libglslang${SUFFIX}.a \
82617a3babSopenharmony_ci                      lib/libglslang-default-resource-limits${SUFFIX}.a \
83617a3babSopenharmony_ci                      lib/libHLSL${SUFFIX}.a \
84617a3babSopenharmony_ci                      lib/libMachineIndependent${SUFFIX}.a \
85617a3babSopenharmony_ci                      lib/libOGLCompiler${SUFFIX}.a \
86617a3babSopenharmony_ci                      lib/libOSDependent${SUFFIX}.a \
87617a3babSopenharmony_ci                      lib/libSPIRV${SUFFIX}.a \
88617a3babSopenharmony_ci                      lib/libSPVRemapper${SUFFIX}.a \
89617a3babSopenharmony_ci                      lib/libSPIRV-Tools${SUFFIX}.a \
90617a3babSopenharmony_ci                      lib/libSPIRV-Tools-opt${SUFFIX}.a
91617a3babSopenharmony_ci            - name: Deploy
92617a3babSopenharmony_ci              if: ${{ matrix.compiler.cc == 'clang' }}
93617a3babSopenharmony_ci              env:
94617a3babSopenharmony_ci                  ARCHIVE: glslang-master-${{matrix.os.family}}-${{matrix.cmake_build_type}}.zip
95617a3babSopenharmony_ci              uses: actions/github-script@v5
96617a3babSopenharmony_ci              with:
97617a3babSopenharmony_ci                  script: |
98617a3babSopenharmony_ci                      const script = require('.github/workflows/deploy.js')
99617a3babSopenharmony_ci                      await script({github, context, core})
100617a3babSopenharmony_ci
101617a3babSopenharmony_ci    macos:
102617a3babSopenharmony_ci        runs-on: ${{matrix.os.genus}}
103617a3babSopenharmony_ci        strategy:
104617a3babSopenharmony_ci            fail-fast: false
105617a3babSopenharmony_ci            matrix:
106617a3babSopenharmony_ci                os: [{genus: macos-10.15, family: osx}]
107617a3babSopenharmony_ci                compiler: [{cc: clang, cxx: clang++}]
108617a3babSopenharmony_ci                cmake_build_type: [Debug, Release]
109617a3babSopenharmony_ci        steps:
110617a3babSopenharmony_ci            - uses: actions/checkout@v2
111617a3babSopenharmony_ci            - uses: actions/setup-python@v2
112617a3babSopenharmony_ci              with:
113617a3babSopenharmony_ci                  python-version: '3.7'
114617a3babSopenharmony_ci            - name: Install GoogleTest
115617a3babSopenharmony_ci              run: |
116617a3babSopenharmony_ci                  # check out pre-breakage version of googletest; can be deleted when
117617a3babSopenharmony_ci                  # issue 3128 is fixed
118617a3babSopenharmony_ci                  # git clone --depth=1 https://github.com/google/googletest.git External/googletest
119617a3babSopenharmony_ci                  mkdir -p External/googletest
120617a3babSopenharmony_ci                  cd External/googletest
121617a3babSopenharmony_ci                  git init
122617a3babSopenharmony_ci                  git remote add origin https://github.com/google/googletest.git
123617a3babSopenharmony_ci                  git fetch --depth 1 origin 0c400f67fcf305869c5fb113dd296eca266c9725
124617a3babSopenharmony_ci                  git reset --hard FETCH_HEAD
125617a3babSopenharmony_ci                  cd ../..
126617a3babSopenharmony_ci            - name: Update Glslang Sources
127617a3babSopenharmony_ci              run: |
128617a3babSopenharmony_ci                  ./update_glslang_sources.py
129617a3babSopenharmony_ci            - name: Build
130617a3babSopenharmony_ci              env:
131617a3babSopenharmony_ci                  CC: ${{matrix.compiler.cc}}
132617a3babSopenharmony_ci                  CXX: ${{matrix.compiler.cxx}}
133617a3babSopenharmony_ci              run: |
134617a3babSopenharmony_ci                  mkdir build && cd build
135617a3babSopenharmony_ci                  cmake -DCMAKE_BUILD_TYPE=${{matrix.cmake_build_type}} -DCMAKE_INSTALL_PREFIX=`pwd`/install ..
136617a3babSopenharmony_ci                  make -j4 install
137617a3babSopenharmony_ci            - name: Test
138617a3babSopenharmony_ci              run: |
139617a3babSopenharmony_ci                  cd build
140617a3babSopenharmony_ci                  ctest --output-on-failure &&
141617a3babSopenharmony_ci                  cd ../Test && ./runtests
142617a3babSopenharmony_ci            - name: Zip
143617a3babSopenharmony_ci              env:
144617a3babSopenharmony_ci                  ARCHIVE: glslang-master-${{matrix.os.family}}-${{matrix.cmake_build_type}}.zip
145617a3babSopenharmony_ci              run: |
146617a3babSopenharmony_ci                  cd build/install
147617a3babSopenharmony_ci                  zip ${ARCHIVE} \
148617a3babSopenharmony_ci                      bin/glslangValidator \
149617a3babSopenharmony_ci                      include/glslang/* \
150617a3babSopenharmony_ci                      lib/libGenericCodeGen${SUFFIX}.a \
151617a3babSopenharmony_ci                      lib/libglslang${SUFFIX}.a \
152617a3babSopenharmony_ci                      lib/libglslang-default-resource-limits${SUFFIX}.a \
153617a3babSopenharmony_ci                      lib/libHLSL${SUFFIX}.a \
154617a3babSopenharmony_ci                      lib/libMachineIndependent${SUFFIX}.a \
155617a3babSopenharmony_ci                      lib/libOGLCompiler${SUFFIX}.a \
156617a3babSopenharmony_ci                      lib/libOSDependent${SUFFIX}.a \
157617a3babSopenharmony_ci                      lib/libSPIRV${SUFFIX}.a \
158617a3babSopenharmony_ci                      lib/libSPVRemapper${SUFFIX}.a \
159617a3babSopenharmony_ci                      lib/libSPIRV-Tools${SUFFIX}.a \
160617a3babSopenharmony_ci                      lib/libSPIRV-Tools-opt${SUFFIX}.a
161617a3babSopenharmony_ci            - name: Deploy
162617a3babSopenharmony_ci              env:
163617a3babSopenharmony_ci                  ARCHIVE: glslang-master-${{matrix.os.family}}-${{matrix.cmake_build_type}}.zip
164617a3babSopenharmony_ci              uses: actions/github-script@v5
165617a3babSopenharmony_ci              with:
166617a3babSopenharmony_ci                  script: |
167617a3babSopenharmony_ci                      const script = require('.github/workflows/deploy.js')
168617a3babSopenharmony_ci                      await script({github, context, core})
169