-
-
Notifications
You must be signed in to change notification settings - Fork 8
124 lines (119 loc) · 3.66 KB
/
build-and-test.yml
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
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 }}"