forked from NewFuture/DDNS
-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (115 loc) · 4.49 KB
/
test-install.yml
File metadata and controls
129 lines (115 loc) · 4.49 KB
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
name: Test Install Script
run-name: "Install Test: ${{ github.event_name == 'pull_request' && format('PR #{0}', github.event.pull_request.number) || github.ref_name }} | ${{ github.event.pull_request.title || 'Manual trigger' }} by ${{ github.actor }}"
permissions:
contents: read
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
paths:
- 'docs/public/install.sh'
- '.github/workflows/test-install.yml'
jobs:
check-changes:
name: Check install.sh or workflow changes
runs-on: ubuntu-latest
outputs:
install-sh-changed: ${{ steps.filter.outputs.install-sh }}
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 2
- name: Check if install.sh or workflow changed
id: filter
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "install-sh=true" >> $GITHUB_OUTPUT
else
# For push events, check if install.sh or workflow file changed in the last commit
if git diff --name-only HEAD^ HEAD | grep -qE "^(docs/public/install.sh|\.github/workflows/test-install\.yml)$"; then
echo "install-sh=true" >> $GITHUB_OUTPUT
else
echo "install-sh=false" >> $GITHUB_OUTPUT
fi
fi
- name: Set matrix based on changes
id: set-matrix
run: |
if [ "${{ steps.filter.outputs.install-sh }}" = "true" ]; then
# Test all platforms when install.sh changed
echo 'matrix=["ubuntu-latest", "ubuntu-24.04-arm", "macos-latest", "macos-15-intel"]' >> $GITHUB_OUTPUT
else
# Test only ubuntu-latest when install.sh hasn't changed
echo 'matrix=["ubuntu-latest"]' >> $GITHUB_OUTPUT
fi
test-install-script:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: check-changes
env:
# Remote installer from the current repository and commit
RAW_URL: ${{ format('https://raw.githubusercontent.com/{0}/{1}/docs/public/install.sh', github.repository, github.sha) }}
strategy:
fail-fast: false
matrix:
os: ${{ fromJSON(needs.check-changes.outputs.matrix) }}
steps:
- name: Test install script help
run: curl -fsSL "$RAW_URL" | sh -s -- --help
- name: Test with bash (if available)
run: curl -fsSL "$RAW_URL" | bash -s -- --help
- name: Test install latest
run: curl -fsSL "$RAW_URL" | sh
- name: Check DDNS
run: ddns --version
- name: Test uninstall
run: curl -fsSL "$RAW_URL" | sh -s -- --uninstall
- name: Test install beta with language detection (zh_CN)
run: curl -fsSL "$RAW_URL" | LANG=zh_CN.UTF-8 sh -s -- beta
- name: Test install help with language detection (zh_CN)
run: curl -fsSL "$RAW_URL" | LANG=zh_CN.UTF-8 sh -s -- --help
- name: Check DDNS
run: ddns --version
- name: Test uninstall
run: curl -fsSL "$RAW_URL" | sh -s -- --uninstall
- name: Test install location by wget
run: wget -qO - "$RAW_URL" | sh -s -- --install-dir /tmp/ddns
- name: Check DDNS in custom location
run: /tmp/ddns/ddns --version
test-with-container:
name: Test on Container (${{ matrix.container }})
runs-on: ubuntu-latest
needs: check-changes
if: needs.check-changes.outputs.install-sh-changed == 'true'
strategy:
matrix:
container:
- alpine:latest
- debian:latest
- openwrt/rootfs:latest
container: ${{ matrix.container }}
env:
# Remote installer from the current repository and commit
RAW_URL: ${{ format('https://raw.githubusercontent.com/{0}/{1}/docs/public/install.sh', github.repository, github.sha) }}
steps:
- name: install wget
if: matrix.container == 'debian:latest'
run: apt-get update && apt-get install -y wget
- name: Download install script
run: wget "$RAW_URL" && chmod +x install.sh
- name: Test install script help
run: ./install.sh --help
- name: Test install latest
run: ./install.sh
- name: Check DDNS
run: ddns --version
- name: Test uninstall
run: ./install.sh --uninstall
- name: Test install beta with language detection (zh_CN)
run: LANG=zh_CN.UTF-8 ./install.sh beta
- name: Check DDNS
run: ddns --version
- name: Test uninstall
run: ./install.sh --uninstall