This repository has been archived by the owner on Dec 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
155 lines (134 loc) · 4.72 KB
/
tests.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
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
name: Test
on:
push:
branches:
- master
pull_request:
env:
ELVISH_VERSION: v0.19.2
NUSHELL_VERSION: 0.77.0
jobs:
detect-changes:
runs-on: ubuntu-latest
permissions:
pull-requests: read
# Set job outputs to values from filter step
outputs:
documentation: ${{ steps.filter.outputs.documentation }}
cli: ${{ steps.filter.outputs.cli }}
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
documentation:
- '.github/workflows/**'
- 'docs/**'
- '.tool-versions'
cli:
- '.github/workflows/**'
- 'bin/**'
- 'lib/**'
- 'scripts/**'
- 'test/**'
- '.tool-versions'
- 'asdf.elv'
- 'asdf.fish'
- 'asdf.nu'
- 'asdf.sh'
ubuntu:
needs: detect-changes
# only run if
# - changes to cli
if: ${{ needs.detect-changes.outputs.cli == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install test dependencies
run: |
sudo add-apt-repository -y ppa:fish-shell/nightly-master
sudo apt-get update
sudo apt-get -y install fish curl parallel
# Create $HOME/bin
mkdir -p "$HOME/bin"
# Download elvish binary and add to path
curl https://dl.elv.sh/linux-amd64/elvish-${{ env.ELVISH_VERSION }}.tar.gz -o elvish-${{ env.ELVISH_VERSION }}.tar.gz
tar xzf elvish-${{ env.ELVISH_VERSION }}.tar.gz
rm elvish-${{ env.ELVISH_VERSION }}.tar.gz
mv elvish-${{ env.ELVISH_VERSION }} "$HOME/bin/elvish"
# Download nushell binary and add to path
curl -L https://github.com/nushell/nushell/releases/download/${{ env.NUSHELL_VERSION }}/nu-${{ env.NUSHELL_VERSION }}-x86_64-unknown-linux-gnu.tar.gz -o nu-${{ env.NUSHELL_VERSION }}-x86_64-unknown-linux-gnu.tar.gz
tar xzf nu-${{ env.NUSHELL_VERSION }}-x86_64-unknown-linux-gnu.tar.gz
rm nu-${{ env.NUSHELL_VERSION }}-x86_64-unknown-linux-gnu.tar.gz
mv nu-${{ env.NUSHELL_VERSION }}-x86_64-unknown-linux-gnu/* "$HOME/bin"
# Add $HOME/bin to path
echo "$HOME/bin" >>"$GITHUB_PATH"
- name: Install bats
run: |
git clone --depth 1 --branch "v$(grep -Eo "^\\s*bats\\s*.*$" ".tool-versions" | cut -d ' ' -f2-)" https://github.com/bats-core/bats-core.git "$HOME/bats-core"
echo "$HOME/bats-core/bin" >>"$GITHUB_PATH"
- name: Run tests
run: scripts/test.bash
env:
GITHUB_API_TOKEN: ${{ github.token }}
macos:
needs: detect-changes
# only run if
# - changes to cli
if: ${{ needs.detect-changes.outputs.cli == 'true' }}
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install test dependencies
run: brew install coreutils parallel fish elvish nushell
- name: Install bats
run: |
git clone --depth 1 --branch "v$(grep -Eo "^\\s*bats\\s*.*$" ".tool-versions" | cut -d ' ' -f2-)" https://github.com/bats-core/bats-core.git "$HOME/bats-core"
echo "$HOME/bats-core/bin" >>"$GITHUB_PATH"
- name: Run tests
run: scripts/test.bash
env:
GITHUB_API_TOKEN: ${{ github.token }}
documentation-site:
needs: detect-changes
# only run if
# - changes to documentation
# - pull_request (workflows/docs.yml deploys on main branch)
if: ${{ github.event_name == 'pull_request' && needs.detect-changes.outputs.documentation == 'true' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
# fetch all commits to get git log info for Vuepress
fetch-depth: 0
# only run steps past here if changes to docs/** directory
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Cache dependencies
uses: actions/cache@v3
id: npm-cache
with:
path: |
docs/node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('docs/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Install dependencies
if: steps.npm-cache.outputs.cache-hit != 'true'
working-directory: docs/
run: npm install
- name: Check errors by building Documentation site
working-directory: docs/
run: npm run build