|
| 1 | +#/ |
| 2 | +# @license Apache-2.0 |
| 3 | +# |
| 4 | +# Copyright (c) 2021 The Stdlib Authors. |
| 5 | +# |
| 6 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +# you may not use this file except in compliance with the License. |
| 8 | +# You may obtain a copy of the License at |
| 9 | +# |
| 10 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +# |
| 12 | +# Unless required by applicable law or agreed to in writing, software |
| 13 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +# See the License for the specific language governing permissions and |
| 16 | +# limitations under the License. |
| 17 | +#/ |
| 18 | + |
| 19 | +# Workflow name: |
| 20 | +name: check_licenses |
| 21 | + |
| 22 | +# Workflow triggers: |
| 23 | +on: [pull_request] |
| 24 | + |
| 25 | +# Workflow jobs: |
| 26 | +jobs: |
| 27 | + |
| 28 | + # Define a job for checking that pull requests do not introduce dependencies which fail license requirements... |
| 29 | + check_licenses: |
| 30 | + |
| 31 | + # Define the type of virtual host machine: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + |
| 34 | + # Define environment variables: |
| 35 | + env: |
| 36 | + BUILD_TASK: 'check_licenses' |
| 37 | + GITHUB: 'true' |
| 38 | + LOG_DIR: "${{ github.workspace }}/tmp/var/log" |
| 39 | + LOG_FILE_BUILD_TASK: "${{ github.workspace }}/tmp/var/log/check_licenses.log" |
| 40 | + LOG_NUM_LINES: 5000 |
| 41 | + |
| 42 | + # Set defaults: |
| 43 | + defaults: |
| 44 | + run: |
| 45 | + # Set the default shell to `bash`: |
| 46 | + shell: bash --noprofile --norc -eo pipefail {0} |
| 47 | + |
| 48 | + # Define the sequence of job steps... |
| 49 | + steps: |
| 50 | + |
| 51 | + # Checkout the repository: |
| 52 | + - name: 'Checkout repository' |
| 53 | + uses: actions/checkout@v2 |
| 54 | + with: |
| 55 | + # Specify whether to remove untracked files before checking out the repository: |
| 56 | + clean: false |
| 57 | + |
| 58 | + # Limit clone depth to the most recent 100 commits: |
| 59 | + fetch-depth: 100 |
| 60 | + |
| 61 | + # Specify whether to download Git-LFS files: |
| 62 | + lfs: false |
| 63 | + timeout-minutes: 10 |
| 64 | + |
| 65 | + # Initialize log files: |
| 66 | + - name: 'Initialize log files' |
| 67 | + run: | |
| 68 | + mkdir -p "${{ env.LOG_DIR }}" |
| 69 | + touch "${{ env.LOG_FILE_BUILD_TASK }}" |
| 70 | + timeout-minutes: 2 |
| 71 | + |
| 72 | + # Install Node.js: |
| 73 | + - name: 'Install Node.js' |
| 74 | + uses: actions/setup-node@v2 |
| 75 | + with: |
| 76 | + node-version: 'lts/*' |
| 77 | + timeout-minutes: 5 |
| 78 | + |
| 79 | + # Print debug info: |
| 80 | + - name: 'Print debug info' |
| 81 | + run: | |
| 82 | + echo 'PATH:' |
| 83 | + echo $PATH |
| 84 | + echo '' |
| 85 | + echo 'Git:' |
| 86 | + git --version |
| 87 | + echo '' |
| 88 | + echo 'Node.js:' |
| 89 | + file $(which node) |
| 90 | + node --version |
| 91 | + node -p 'process.platform + "@" + process.arch' |
| 92 | + echo '' |
| 93 | + echo 'npm:' |
| 94 | + npm --version |
| 95 | + npm config get registry |
| 96 | + timeout-minutes: 2 |
| 97 | + |
| 98 | + # Perform install sequence (accounting for possible network failures, etc, when installing node module dependencies): |
| 99 | + - name: 'Perform install sequence' |
| 100 | + run: | |
| 101 | + npm install || npm install || npm install |
| 102 | + timeout-minutes: 30 |
| 103 | + |
| 104 | + # Run the build task: |
| 105 | + - name: 'Run build task' |
| 106 | + run: | |
| 107 | + . "$GITHUB_WORKSPACE/.github/workflows/scripts/task_runner" "${{ env.BUILD_TASK }}" "${{ env.LOG_FILE_BUILD_TASK }}" |
| 108 | + timeout-minutes: 360 |
| 109 | + |
| 110 | + # View the log file if the previous step fails: |
| 111 | + - name: 'View log file' |
| 112 | + if: failure() |
| 113 | + run: | |
| 114 | + echo "Printing the last ${{ env.LOG_NUM_LINES }} lines of log output..." |
| 115 | + tail -${{ env.LOG_NUM_LINES }} "${{ env.LOG_FILE_BUILD_TASK }}" |
| 116 | + timeout-minutes: 5 |
| 117 | + |
| 118 | + # Upload the log file: |
| 119 | + - name: 'Upload log file' |
| 120 | + uses: actions/upload-artifact@v2 |
| 121 | + if: always() |
| 122 | + with: |
| 123 | + # Define a name for the uploaded artifact: |
| 124 | + name: ${{ env.BUILD_TASK }}_log |
| 125 | + |
| 126 | + # Specify the path to the file to upload: |
| 127 | + path: ${{ env.LOG_FILE_BUILD_TASK }} |
| 128 | + |
| 129 | + # Specify the number of days to retain the artifact (default is 90 days): |
| 130 | + retention-days: 14 |
| 131 | + timeout-minutes: 10 |
0 commit comments