Skip to content

Commit 1bf42fd

Browse files
authored
Merge pull request #569 from ivan-hc/dev
New code refactoring
2 parents 8db29dd + f54cfc0 commit 1bf42fd

23 files changed

+1473
-1083
lines changed

.github/workflows/lint-shell.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
name: 🐶 SHELL check 🧪
3+
on:
4+
push:
5+
branches: '**'
6+
paths:
7+
- 'modules/**'
8+
- INSTALL
9+
- APP-MANAGER
10+
- '!programs/**'
11+
pull_request:
12+
branches: '**'
13+
paths:
14+
- 'modules/**'
15+
- INSTALL
16+
- APP-MANAGER
17+
- '!programs/**'
18+
workflow_dispatch:
19+
concurrency:
20+
group: ${{ github.workflow }}-${{ github.ref }}
21+
cancel-in-progress: true
22+
jobs:
23+
reviewdog:
24+
permissions:
25+
checks: write
26+
contents: read
27+
pull-requests: write
28+
name: shellcheck
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- uses: haya14busa/action-cond@v1
34+
id: reporter
35+
with:
36+
cond: ${{ github.event_name == 'pull_request' }}
37+
38+
- uses: reviewdog/action-shellcheck@v1
39+
with:
40+
reporter: ${{ steps.reporter.outputs.value }}
41+
github_token: ${{ secrets.github_token }}
42+
path: |
43+
"."
44+
modules
45+
exclude: "./programs/*"
46+
check_all_files_with_shebangs: true
47+
level: error
48+
shellcheck_flags: '--external-sources --severity=error'
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: "Lint Shellcheck 🐚"
2+
3+
on:
4+
pull_request:
5+
branches: '**'
6+
workflow_dispatch:
7+
8+
jobs:
9+
shellcheck:
10+
name: Shellcheck
11+
runs-on: ubuntu-22.04
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Run ShellCheck
15+
uses: ludeeus/action-shellcheck@master
16+
with:
17+
format: gcc
18+
severity: error

.github/workflows/lint-yaml.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
name: 🐶 YAML check 🧪
3+
on:
4+
push:
5+
branches: '**'
6+
path: .github/workflows/*.yml
7+
pull_request:
8+
branches: '**'
9+
path: .github/workflows/*.yml
10+
workflow_dispatch:
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
jobs:
15+
yamllint:
16+
name: yaml lint
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v4
20+
- uses: haya14busa/action-cond@v1
21+
id: reporter
22+
with:
23+
cond: ${{ github.event_name == 'pull_request' }}
24+
- uses: reviewdog/action-yamllint@v1
25+
with:
26+
reporter: ${{ steps.reporter.outputs.value }}
27+
github_token: ${{ secrets.github_token }}
28+
yamllint_flags: '-d relaxed .github/'
29+
level: error

.github/workflows/test-apps.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: "Apps test 🧪"
2+
3+
env:
4+
TERM: xterm
5+
6+
on:
7+
workflow_dispatch:
8+
branches: '**'
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
15+
am:
16+
name: test all Apps 📝
17+
runs-on: ubuntu-22.04
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: test all Apps
21+
run: |
22+
printf '\tSetting up environment...\n'
23+
printf '\n\tCreating directory structure...\n'
24+
mkdir -p results
25+
printf '\n\tMaking needed files executable...\n'
26+
chmod +x ./INSTALL
27+
printf '\n\tInstalling AM...\n'
28+
sudo ./INSTALL
29+
printf '\n'
30+
echo -e "Installed version: $(am version)\n\n"
31+
apps=$(cut -d' ' -f2 < /opt/am/x86_64-apps)
32+
count=$(echo "${apps}" | wc -l)
33+
echo "available apps: $count"
34+
for app in ${apps}; do
35+
echo '-------------------------------------------------------------'
36+
am -f -less
37+
echo '-------------------------------------------------------------'
38+
am -i $app && echo "OK: $app" >> results/good || \
39+
echo "FAIL! $app" >> results/bad
40+
echo '-------------------------------------------------------------'
41+
am -f --less
42+
echo '-------------------------------------------------------------'
43+
am -R $app && echo "OK: $app" >> results/removed || \
44+
echo "REMOVE! $app" >> results/noremoved
45+
echo '-------------------------------------------------------------'
46+
am -f --less
47+
echo '-------------------------------------------------------------'
48+
done
49+
good=$(cat results/good | wc -l)
50+
bad=$(cat results/bad | wc -l)
51+
removed=$(cat results/removed | wc -l)
52+
noremoved=$(cat results/noremoved | wc -l)
53+
echo -e "\n\n"
54+
echo "all/runed/ok/failed/removed/not"
55+
echo "$count/$n/$good/$bad/$removed/$noremoved"
56+
echo -e "\n\n"
57+
printf '\n\tTest finished\n'
58+
- uses: actions/upload-artifact@v4
59+
with:
60+
name: results
61+
path: results

.github/workflows/test.sh

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env bash
2+
3+
# Simple script for testing all functions of AM
4+
5+
n=0
6+
((n++))
7+
function _check() {
8+
printf '%s - %s\n\n%s' "${1}" "${3}" "$(am ${2} || echo "FAIL: ${1}" && exit $n)"
9+
}
10+
11+
function list_apps() {
12+
am list
13+
}
14+
15+
function _pick_app() {
16+
randomApp=$(cut -d' ' -f2 < /opt/am/x86_64-apps | shuf -n 1)
17+
}
18+
19+
# Test needs: Items in brackets [] are optional
20+
# Use '' or "" for arguments with more words!
21+
#_check <Name of test> <command> [Short info]
22+
23+
_pick_app
24+
printf '\n-----------------------------------------------------------------------------\n\n\t\tAM testing started\n\n-----------------------------------------------------------------------------\n\n'
25+
_check am am 'no argument'
26+
27+
printf '\n-----------------------------------------------------------------------------\n\n'
28+
_check version version
29+
30+
printf '\n-----------------------------------------------------------------------------\n\n'
31+
_check 'files --less' 'files --less' 'Number of installed apps'
32+
33+
printf '\n-----------------------------------------------------------------------------\n\n'
34+
_check "install ${randomApp}" "install ${randomApp}" "Install random app"
35+
36+
printf '\n-----------------------------------------------------------------------------\n\n'
37+
_check 'files --less' 'files --less' 'Installed apps'
38+
39+
#_check files files 'Installed apps'
40+
41+
#_check 'files --byname' 'files --byname' 'Installed apps by name'
42+
43+
#_check help help 'Help message'
44+
45+
#_check 'update apps' 'update --apps' 'Update Apps'
46+
47+
#_check list list 'List available Apps'
48+
49+
printf '\n-----------------------------------------------------------------------------\n\n'
50+
_check "remove ${randomApp}" "remove ${randomApp}" "Remove random app"
51+
52+
printf '\n-----------------------------------------------------------------------------\n\n'
53+
_check 'files --less' 'files --less' 'Number of installed apps'
54+
55+
printf '\n-----------------------------------------------------------------------------\n\n'
56+
57+
printf '\n-----------------------------------------------------------------------------\n\n'
58+
59+
printf '\n-----------------------------------------------------------------------------\n\n'
60+
61+
printf '\n-----------------------------------------------------------------------------\n\n'
62+
63+
printf '\n-----------------------------------------------------------------------------\n\n'
64+
65+
printf '\n-----------------------------------------------------------------------------\n\n'
66+
67+
printf '\n-----------------------------------------------------------------------------\n\n\t\tAM testing Finished\n\n-----------------------------------------------------------------------------\n\n'
68+
69+
exit 0

.github/workflows/test.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: "AM test suite 🧪"
2+
3+
env:
4+
TERM: xterm
5+
6+
on:
7+
push:
8+
branches: '**'
9+
paths:
10+
- 'modules/**'
11+
- INSTALL
12+
- APP-MANAGER
13+
- '!programs/**'
14+
pull_request:
15+
branches: '**'
16+
paths:
17+
- 'modules/**'
18+
- INSTALL
19+
- APP-MANAGER
20+
- '!programs/**'
21+
workflow_dispatch:
22+
concurrency:
23+
group: ${{ github.workflow }}-${{ github.ref }}
24+
cancel-in-progress: true
25+
26+
jobs:
27+
28+
am:
29+
name: Install AM 📝
30+
runs-on: ubuntu-22.04
31+
steps:
32+
- uses: actions/checkout@v4
33+
- name: Install AM
34+
run: |
35+
ls -al .github/workflows
36+
printf '\tSetting up environment...\n'
37+
printf '\n\tCreating directory structure...\n'
38+
mkdir -p results /usr/local/bin
39+
# printf '\n\tUpgrading ubuntu host...\n'
40+
# sudo apt update && sudo apt upgrade
41+
printf '\n\tInstalling dependencies...\n'
42+
sudo apt install -y wget curl zsync 2> /dev/null
43+
printf '\n\tMaking needed files executable...\n'
44+
chmod +x ./INSTALL .github/workflows/test.sh
45+
printf '\n\tInstalling AM...\n'
46+
sudo ./INSTALL
47+
printf '\n'
48+
echo "Installed version: $(am version)"
49+
printf '\n\tRunning tests...\n'
50+
.github/workflows/test.sh
51+
printf '\n\tTest finished succesfully\n'
52+
53+
# t:
54+
# name: t
55+
# runs-on: ubuntu-22.04
56+
# steps:
57+
# - uses: actions/checkout@v4
58+
# - name: t
59+
# run: |
60+
# printf '\t...\n\n'
61+
# printf '\n\n\t...\n\n'
62+
# echo hello
63+
# printf '\n\n\tDONE\n\n'

0 commit comments

Comments
 (0)