Build & Test #387
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-and-test | |
run-name: Build & Test | |
on: | |
workflow_dispatch: | |
inputs: | |
ubuntu: | |
description: 'Build & Test on Ubuntu latest ?' | |
default: true | |
required: true | |
type: boolean | |
macos: | |
description: 'Build & Test on macOS latest ?' | |
default: false | |
required: true | |
type: boolean | |
push: | |
branches: | |
- 'master' | |
paths: | |
- 'bin/**' | |
- 'dotfiles/**' | |
- 'tests/**' | |
- '**/*.bash' | |
fork: | |
branches: | |
- '**' | |
pull_request: | |
branches: | |
- '**' | |
paths: | |
- 'bin/**' | |
- 'dotfiles/**' | |
- 'tests/**' | |
- '**/*.bash' | |
permissions: | |
contents: write | |
env: | |
JOB_NAME: "HomeSetup-Build" | |
jobs: | |
set-os-matrix: | |
runs-on: "ubuntu-latest" | |
outputs: | |
matrix-os: ${{ steps.set-matrix-items.outputs.matrix-os }} | |
steps: | |
- name: Show Selected Input | |
run: | | |
echo "Build on Ubuntu-Latest: ${{ inputs.ubuntu || false }}" | |
echo "Build on MacOS-Latest: ${{ inputs.macos || false }}" | |
- name: Set Inclusion Matrix | |
id: set-matrix-items | |
run: | | |
JSON="" | |
if [[ "${{ inputs.ubuntu }}" == "true" ]]; then | |
JSON="\"ubuntu-latest\"" | |
fi | |
if [[ "${{ inputs.macos }}" == "true" ]]; then | |
[[ -n "$JSON" ]] && JSON="${JSON}, " | |
JSON="${JSON} \"macos-latest\"" | |
fi | |
[[ -z "${JSON}" ]] && JSON="\"ubuntu-latest\"" | |
JSON="[${JSON}]" | |
echo "JSON: ${JSON}" | |
echo "matrix-os=$( echo "${JSON}" )" >> $GITHUB_OUTPUT | |
build: | |
needs: set-os-matrix | |
strategy: | |
matrix: | |
os: ${{ fromJson(needs.set-os-matrix.outputs.matrix-os) }} | |
runs-on: ${{ matrix.os }} | |
env: | |
PREFIX: "${{ github.workspace }}" | |
HHS_LOG_DIR: "${{ matrix.os == 'macos-latest' && '/Users/runner/.config/hhs/log' || '/home/runner/.config/hhs/log' }}" | |
LC_ALL: "${{ vars.LC_ALL }}" | |
GOOGLE_API_KEY: "${{ secrets.GOOGLE_API_KEY }}" | |
DEEPL_API_KEY: "${{ secrets.DEEPL_API_KEY }}" | |
OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}" | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ vars.PYTHON_VERSION }} | |
- name: Update PIP | |
run: pip install --upgrade pip | |
- name: Install HomeSetup with Prefix | |
run: | | |
if ./install.bash -r -p "${PREFIX}"; then | |
echo "${PREFIX}" > "${HOME}/.hhs-prefix" | |
echo "## Installation information" >> $GITHUB_STEP_SUMMARY | |
echo " SHELL: ${SHELL}" >> $GITHUB_STEP_SUMMARY | |
echo "PREFIX: ${PREFIX}" >> $GITHUB_STEP_SUMMARY | |
echo " HOME: ${HOME}" >> $GITHUB_STEP_SUMMARY | |
echo " USER: ${USER}" >> $GITHUB_STEP_SUMMARY | |
echo " LOGS: ${HHS_LOG_DIR}" >> $GITHUB_STEP_SUMMARY | |
echo -en "${BLUE}Loading bash profile... " | |
if source "${HOME}/.bashrc"; then | |
echo -e "${GREEN}OK${NC}" | |
__hhs tests && exit 0 | |
else | |
echo -e "${GREEN}FAILED${NC}" | |
fi | |
else | |
echo "HHS_LOG_DIR=$(echo ${HOME}/install.log)" >> $GITHUB_ENV | |
fi | |
exit 1 | |
- name: Upload installation logs (success) | |
if: ${{ success() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: "success-install-logs" | |
path: "${{ env.HHS_LOG_DIR }}" | |
- name: Upload installation logs (failure) | |
if: ${{ failure() }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: "failure-install-logs" | |
path: "${{ env.HHS_LOG_DIR }}" |