summaryrefslogtreecommitdiff
path: root/.github/workflows/build.yaml
blob: 3ea58d9c0971f3f68904d96571c7beb58e5c730e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
name: Build

on:
  workflow_dispatch:
  pull_request:
  push:
    branches: ["actions*"]
    tags: ["*"]

jobs:
  build:
    strategy:
      matrix:
        runner: [windows-large, macos-12-xl]
        configuration: [Release]
        python-version: ["3.11"]
        include:
          - runner: macos-12-xl
            developer_dir: "/Applications/Xcode_14.0.1.app/Contents/Developer"
    runs-on: ${{ matrix.runner }}
    outputs:
      # pass these from build job to release job
      installer: ${{ steps.build.outputs.installer }}
      metadata: ${{ steps.build.outputs.metadata }}
    env:
      AUTOBUILD_ADDRSIZE: 64
      AUTOBUILD_BUILD_ID: ${{ github.run_id }}
      AUTOBUILD_CONFIGURATION: ${{ matrix.configuration }}
      # authorizes fetching private constituent packages
      AUTOBUILD_GITHUB_TOKEN: ${{ secrets.SHARED_AUTOBUILD_GITHUB_TOKEN }}
      AUTOBUILD_INSTALLABLE_CACHE: ${{ github.workspace }}/.autobuild-installables
      AUTOBUILD_VARIABLES_FILE: ${{ github.workspace }}/.build-variables/variables
      AUTOBUILD_VSVER: "170"
      DEVELOPER_DIR: ${{ matrix.developer_dir }}
      # Ensure that viewer builds engage Bugsplat.
      BUGSPLAT_DB: "SecondLife_Viewer_2018"
      BUGSPLAT_PASS: ${{ secrets.BUGSPLAT_PASS }}
      BUGSPLAT_USER: ${{ secrets.BUGSPLAT_USER }}
      build_coverity: false
      build_log_dir: ${{ github.workspace }}/.logs
      build_viewer: true
      BUILDSCRIPTS_SHARED: ${{ github.workspace }}/.shared
      # extracted and committed to viewer repo
      BUILDSCRIPTS_SUPPORT_FUNCTIONS: ${{ github.workspace }}/buildscripts_support_functions
      GIT_REF: ${{ github.head_ref || github.ref }}
      LL_SKIP_REQUIRE_SYSROOT: 1
      # Setting this variable directs Linden's TUT test driver code to capture
      # test-program log output at the specified level, but to display it only if
      # the individual test fails.
      LOGFAIL: DEBUG
      master_message_template_checkout: ${{ github.workspace }}/.master-message-template
      # Only set variants to the one configuration: don't let build.sh loop
      # over variants, let GitHub distribute variants over multiple hosts.
      variants: ${{ matrix.configuration }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v3
        with:
          ref: ${{ github.event.pull_request.head.sha || github.sha }}

      - name: Setup python
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}

      - name: Checkout build variables
        uses: actions/checkout@v3
        with:
          repository: secondlife/build-variables
          ref: viewer
          path: .build-variables

      - name: Checkout master-message-template
        uses: actions/checkout@v3
        with:
          repository: secondlife/master-message-template
          path: .master-message-template

      - name: Install autobuild
        run: pip3 install autobuild llsd

      - name: Cache autobuild packages
        uses: actions/cache@v3
        id: cache-installables
        with:
          path: .autobuild-installables
          key: ${{ runner.os }}-${{ matrix.addrsize }}-${{ matrix.configuration }}-${{ hashFiles('autobuild.xml') }}
          restore-keys: |
            ${{ runner.os }}-${{ matrix.addrsize }}-${{ matrix.configuration }}-
            ${{ runner.os }}-${{ matrix.addrsize }}-

      - name: Install windows dependencies
        if: runner.os == 'Windows'
        run: choco install nsis-unicode

      - name: Build
        id: build
        shell: bash
        env:
          RUNNER_OS: ${{ runner.os }}
        run: |
          # set up things the viewer's build.sh script expects
          set -x
          mkdir -p "$build_log_dir"
          mkdir -p "$BUILDSCRIPTS_SHARED/packages/lib/python"
          source "$BUILDSCRIPTS_SUPPORT_FUNCTIONS"
          if [[ "$OSTYPE" =~ cygwin|msys ]]
          then
            native_path() { cygpath --windows "$1"; }
            shell_path()  { cygpath --unix "$1"; }
          else
            native_path() { echo "$1"; }
            shell_path()  { echo "$1"; }
          fi
          finalize()
          {
            case "$1" in
              true|0)
                record_success "Build Succeeded"
                ;;
              *)
                record_failure "Build Failed with $1"
                ;;
            esac
          }
          initialize_build()
          {
            echo "initialize_build"
          }
          initialize_version()
          {
            export revision="$AUTOBUILD_BUILD_ID"
          }
          python_cmd()
          {
              if [[ "x${1:0:1}" == "x-" ]]    # -m, -c, etc.
              then # if $1 is a switch, don't try to twiddle paths
                   "$(shell_path "$PYTHON_COMMAND")" "$@"
              elif [[ "$(basename "$1")" == "codeticket.py" ]]
              then # ignore any attempt to contact codeticket
                   echo "## $@"
              else # running a script at an explicit path: fix path for Python
                   local script="$1"
                   shift
                   "$(shell_path "$PYTHON_COMMAND")" "$(native_path "$script")" "$@"
              fi
          }
          repo_branch()
          {
            git -C "$1" branch | grep '^* ' | cut -c 3-
          }
          record_dependencies_graph()
          {
            echo "TODO: generate and post dependency graph"
          }
          # Since we're not uploading to codeticket, DO NOT sleep for minutes.
          sleep()
          {
            echo "Not sleeping for $1 seconds"
          }
          export -f native_path shell_path finalize initialize_build initialize_version
          export -f python_cmd repo_branch record_dependencies_graph sleep
          ## Useful for diagnosing Windows LLProcess/LLLeap test failures
          ##export APR_LOG="${RUNNER_TEMP}/apr.log"
          export arch=$(uname | cut -b-6)
          # Surprise! GH Windows runner's MINGW6 is a $arch value we've never
          # seen before, so numerous tests don't know about it.
          [[ "$arch" == "MINGW6" ]] && arch=CYGWIN
          export AUTOBUILD="$(which autobuild)"
          # Build with a tag like "Second_Life_Project_Shiny#abcdef0" to get a
          # viewer channel "Second Life Project Shiny" (ignoring "#hash",
          # needed to disambiguate tags).
          if [[ "$GITHUB_REF_TYPE" == "tag" && "${GITHUB_REF_NAME:0:12}" == "Second_Life_" ]]
          then viewer_channel="${GITHUB_REF_NAME%#*}"
               export viewer_channel="${viewer_channel//_/ }"
          else export viewer_channel="Second Life Test"
          fi

          # On windows we need to point the build to the correct python
          # as neither CMake's FindPython nor our custom Python.cmake module
          # will resolve the correct interpreter location.
          if [[ "$RUNNER_OS" == "Windows" ]]; then
            export PYTHON="$(native_path "$(which python)")"
            echo "Python location: $PYTHON"
            export PYTHON_COMMAND="$PYTHON"
          else
            export PYTHON_COMMAND="python3"
          fi
          export PYTHON_COMMAND_NATIVE="$(native_path "$PYTHON_COMMAND")"

          ./build.sh

          # Each artifact is downloaded as a distinct .zip file. Multiple jobs
          # (per the matrix above) writing the same filepath to the same
          # artifact name will *overwrite* that file. Moreover, they can
          # interfere with each other, causing the upload to fail.
          # https://github.com/actions/upload-artifact#uploading-to-the-same-artifact
          # Given the size of our installers, and the fact that we typically
          # only want to download just one instead of a single zip containing
          # several, generate a distinct artifact name for each installer.
          # If the matrix above can run multiple builds on the same
          # platform, we must disambiguate on more than the platform name.
          # e.g. if we were still running Windows 32-bit builds, we'd need to
          # qualify the artifact with bit width.
          echo "artifact=$RUNNER_OS" >> $GITHUB_OUTPUT

      - name: Upload installer
        uses: actions/upload-artifact@v3
        with:
          name: "${{ steps.build.outputs.artifact }} installer"
          # emitted by build.sh, possibly multiple lines
          path: |
            ${{ steps.build.outputs.installer }}

      # The other upload of nontrivial size is the symbol file. Use a distinct
      # artifact for that too.
      - name: Upload symbol file
        uses: actions/upload-artifact@v3
        with:
          name: "${{ steps.build.outputs.artifact }} symbols"
          path: |
            ${{ steps.build.outputs.symbolfile }}

      - name: Upload metadata
        uses: actions/upload-artifact@v3
        with:
          name: "${{ steps.build.outputs.artifact }} metadata"
          # emitted by build.sh, possibly multiple lines
          path: |
            ${{ steps.build.outputs.metadata }}

      - name: Upload physics package
        uses: actions/upload-artifact@v3
        # should only be set for viewer-private
        if: steps.build.outputs.physicstpv
        with:
          name: "${{ steps.build.outputs.artifact }} physics"
          # emitted by build.sh, zero or one lines
          path: |
            ${{ steps.build.outputs.physicstpv }}

  release:
    needs: build
    runs-on: [ubuntu-latest]
    if: github.ref_type == 'tag' && startsWith(github.ref_name, 'Second_Life_')
    steps:
      # forked from softprops/action-gh-release
      - uses: secondlife-3p/action-gh-release@v1
        with:
          generate_release_notes: true
          files: |
            ${{ jobs.build.outputs.installer }}
            ${{ jobs.build.outputs.metadata }}