mirror of
https://github.com/armbian/scripts.git
synced 2026-01-06 10:32:48 -08:00
413 lines
16 KiB
YAML
413 lines
16 KiB
YAML
name: Smoke tests
|
|
on:
|
|
workflow_dispatch:
|
|
workflow_call:
|
|
inputs:
|
|
GITBRANCH:
|
|
required: true
|
|
type: string
|
|
default: "main"
|
|
PWRMNGMT:
|
|
required: true
|
|
type: string
|
|
default: "true"
|
|
BETAONLY:
|
|
required: false
|
|
type: string
|
|
default: "true"
|
|
secrets:
|
|
ACCESS_TOKEN_ARMBIANWORKER:
|
|
required: true
|
|
NETBOX_TOKEN:
|
|
required: true
|
|
KEY_CI:
|
|
required: true
|
|
KEY_POWER_ON:
|
|
required: true
|
|
KEY_POWER_OFF:
|
|
required: true
|
|
USER_REPOSITORY:
|
|
required: true
|
|
HOST_REPOSITORY:
|
|
required: true
|
|
KNOWN_HOSTS_REPOSITORY:
|
|
required: true
|
|
jobs:
|
|
|
|
Prepare:
|
|
name: "Power system on"
|
|
outputs:
|
|
matrix: ${{steps.json.outputs.JSON_CONTENT}}
|
|
runs-on: [self-hosted, Linux, local]
|
|
steps:
|
|
|
|
- name: "Power on"
|
|
if: ${{ inputs.PWRMNGMT == 'true' }}
|
|
uses: armbian/actions/power-on@main
|
|
with:
|
|
KEY_POWER_ON: ${{ secrets.KEY_POWER_ON }}
|
|
USER_REPOSITORY: ${{ secrets.USER_REPOSITORY }}
|
|
HOST_REPOSITORY: ${{ secrets.HOST_REPOSITORY }}
|
|
KNOWN_HOSTS_REPOSITORY: ${{ secrets.KNOWN_HOSTS_REPOSITORY }}
|
|
|
|
- name: Get devices from database
|
|
id: json
|
|
run: |
|
|
|
|
echo 'JSON_CONTENT<<EOF' >> $GITHUB_OUTPUT
|
|
curl -H "Authorization: Token ${{ secrets.NETBOX_TOKEN }}" -H "Accept: application/json; indent=4" \
|
|
"https://stuff.armbian.com/netbox/api/dcim/devices/?limit=500&name__empty=false&tenant=igor&status=active&device_role=DUT&tag=qa" \
|
|
| jq '.results[] | .device_type.slug, .id, .primary_ip.address' | xargs -n3 -d'\n' | grep -v null \
|
|
| sed 's/\/24"/"/g' | sed "s/ /:/g" | sed "s/\"//g" |jq -cnR '[inputs | select(length>0)]' | jq >> $GITHUB_OUTPUT
|
|
echo 'EOF' >> $GITHUB_OUTPUT
|
|
|
|
Test:
|
|
name: "DUT"
|
|
runs-on: [igor]
|
|
needs: Prepare
|
|
if: ${{ needs.Prepare.outputs.matrix != '[]' && needs.Prepare.outputs.matrix != '' }}
|
|
timeout-minutes: 90
|
|
strategy:
|
|
max-parallel: 64
|
|
fail-fast: false
|
|
matrix:
|
|
|
|
node: ${{fromJson(needs.Prepare.outputs.matrix)}}
|
|
|
|
steps:
|
|
|
|
- name: Runner clean
|
|
uses: armbian/actions/runner-clean@main
|
|
|
|
- name: Checkout Armbian OS repo
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: armbian/scripts
|
|
fetch-depth: 1
|
|
clean: false
|
|
path: scripts
|
|
|
|
- name: Checkout Armbian build repo
|
|
uses: actions/checkout@v4
|
|
with:
|
|
repository: armbian/build
|
|
fetch-depth: 0
|
|
ref: "${{ inputs.GITBRANCH }}"
|
|
clean: false
|
|
path: build
|
|
|
|
- name: Install SSH key for storage
|
|
uses: shimataro/ssh-key-action@v2.5.1
|
|
with:
|
|
key: ${{ secrets.KEY_CI }}
|
|
known_hosts: github.com ssh-rsa AAAAB3Nz
|
|
if_key_exists: replace
|
|
|
|
- name: Read values
|
|
run: |
|
|
|
|
# read matrix
|
|
CHUNK="${{ matrix.node }}"
|
|
|
|
# extract values
|
|
DUT_SLUG=$(echo $CHUNK | cut -d":" -f1)
|
|
DUT_ID=$(echo $CHUNK | cut -d":" -f2)
|
|
DUT_IP=$(echo $CHUNK | cut -d":" -f3)
|
|
|
|
# save to environment
|
|
echo "DUT_SLUG=$DUT_SLUG" >> $GITHUB_ENV
|
|
echo "DUT_ID=$DUT_ID" >> $GITHUB_ENV
|
|
echo "DUT_IP=$DUT_IP" >> $GITHUB_ENV
|
|
|
|
# read config type
|
|
DUT_CONF_TYPE=$(ls -1 build/config/boards/$DUT_SLUG.* | sed 's/.*\.//')
|
|
|
|
# read board configs and save to environment
|
|
CFG_CONTENT="$(cat build/config/boards/${DUT_SLUG}.* | grep -e "KERNEL_TARGET\|KERNEL_TEST_TARGET\|BOARD_NAME\|BOARD_MAINTAINER")"
|
|
eval "$CFG_CONTENT"
|
|
echo "BOARD_NAME=$BOARD_NAME" >> $GITHUB_ENV
|
|
[[ -n "${KERNEL_TEST_TARGET}" ]] && KERNEL_TARGET="${KERNEL_TEST_TARGET}"
|
|
echo "KERNEL_TARGET=$KERNEL_TARGET" >> $GITHUB_ENV
|
|
if [[ -n "${BOARD_MAINTAINER}" && "${DUT_CONF_TYPE}" == "conf" ]]; then
|
|
echo "DUT_CONF_TYPE=<a href=https://docs.armbian.com/User-Guide_Board-Support-Rules/><img src=https://img.shields.io/static/v1?label=&message=Standard&color=green></a>" >> $GITHUB_ENV
|
|
elif [[ "${DUT_CONF_TYPE}" == "wip" ]]; then
|
|
echo "DUT_CONF_TYPE=<a href=https://docs.armbian.com/User-Guide_Board-Support-Rules/><img src=https://img.shields.io/static/v1?label=&message=Staging&color=orange></a>" >> $GITHUB_ENV
|
|
else
|
|
echo "DUT_CONF_TYPE=<a href=https://docs.armbian.com/User-Guide_Board-Support-Rules/><img src=https://img.shields.io/static/v1?label=&message=Community&color=white></a>" >> $GITHUB_ENV
|
|
fi
|
|
|
|
# read power connector id
|
|
CFG_CONTENT=$(curl -H "Authorization: Token ${{ secrets.NETBOX_TOKEN }}" -H "Accept: application/json; indent=4" \
|
|
"https://stuff.armbian.com/netbox/api/dcim/power-ports/?limit=500&name__empty=false&device_id=$DUT_ID" \
|
|
| jq '.results[] | .link_peer.display')
|
|
echo "POWER_PORT=$(echo $CFG_CONTENT | cut -d'(' -f2 | cut -d')' -f1 | grep -Eo '[0-9]{1,4}')" >> $GITHUB_ENV
|
|
|
|
- name: "Is ${{ env.DUT_IP }} online via power port ${{ env.POWER_PORT }} ?"
|
|
run: |
|
|
|
|
# set this here
|
|
echo "REBOOT=false" >> $GITHUB_ENV
|
|
|
|
[[ -z $(command -v nc) ]] && sudo apt-get -yy install netcat
|
|
|
|
server="${{ env.DUT_IP }}"
|
|
scanning=0
|
|
broken=0
|
|
while [[ ${scanning} -lt 3 ]]; do
|
|
sleep 0.5
|
|
scanning=$(( scanning + 1 )) || broken=1; break
|
|
nc -z $server 22 -w 15 || broken=1
|
|
done
|
|
if [[ ${broken} == 1 ]]; then
|
|
echo "$server ✗ needs to be power cycled"
|
|
[[ -n "${{ env.POWER_PORT }}" ]] && ssh -o StrictHostKeyChecking=no root@10.0.40.6 "./restart ${{ env.POWER_PORT }}" || true
|
|
echo "STATUS=failed" >> $GITHUB_ENV
|
|
else
|
|
echo "$server ✓"
|
|
echo "PROCEED=true" >> $GITHUB_ENV
|
|
echo "ONLINE=true" >> $GITHUB_ENV
|
|
fi
|
|
|
|
- name: First run and copy ssh keys to the DUT
|
|
timeout-minutes: 30
|
|
if: ${{ github.repository_owner == 'Armbian' && env.STATUS == '' }}
|
|
run: |
|
|
|
|
[[ -z $(command -v sshpass) ]] && sudo apt-get -yy install sshpass
|
|
|
|
mkdir -p ~/.ssh/
|
|
cp scripts/autotests.pub ~/.ssh/id_rsa.pub
|
|
ls -l ~/.ssh/
|
|
export TERM=vt100
|
|
|
|
USER_HOST=10.0.10.238
|
|
# login credentials
|
|
USER_ROOT=root
|
|
PASS_ROOT=testpassword
|
|
USER_NORMAL=guest
|
|
PASS_NORMAL=testpassword
|
|
REPLACE_KEY=true
|
|
|
|
# clean
|
|
ssh-keygen -qf "$HOME/.ssh/known_hosts" -R "${{ env.DUT_IP }}" > /dev/null 2>&1
|
|
|
|
if [[ "$(ssh -o StrictHostKeyChecking=accept-new -o BatchMode=yes -o ConnectTimeout=10 root@${{ env.DUT_IP }} "w " 2>&1 | grep "Permission denied")" ]]; then
|
|
if [[ ! "$(sshpass -p 1234 ssh -o "StrictHostKeyChecking=accept-new" -o ConnectTimeout=10 ${USER_ROOT}@${{ env.DUT_IP }} "w " 2>&1 | grep "Permission denied")" == "Permission denied"* ]]; then
|
|
expect -c "
|
|
spawn sshpass -p 1234 ssh -o "StrictHostKeyChecking=accept-new" -o ConnectTimeout=10 ${USER_ROOT}@${{ env.DUT_IP }}
|
|
set timeout 120
|
|
expect \"Create root password: \"
|
|
send \"${PASS_ROOT}\r\"
|
|
expect \"Repeat root password: \"
|
|
send \"${PASS_ROOT}\r\"
|
|
expect \"zsh\"
|
|
send \"2\r\"
|
|
expect \"*to abort\"
|
|
send \"${USER_NORMAL}\r\"
|
|
expect \"Create*password:\"
|
|
send \"${PASS_NORMAL}\r\"
|
|
expect \"Repeat*password:\"
|
|
send \"${PASS_NORMAL}\r\"
|
|
expect \"Please provide your real name: \"
|
|
send \"${NAME_NORMAL}\r\"
|
|
expect \"*language based on your location*\"
|
|
send \"y\r\"
|
|
expect \"*#\"
|
|
send \"exit\r\"
|
|
"
|
|
fi
|
|
fi
|
|
sleep 4
|
|
echo "Install keys always"
|
|
sshpass -p "${PASS_ROOT}" ssh-copy-id -i ~/.ssh/id_rsa.pub -o "StrictHostKeyChecking=accept-new" root@${{ env.DUT_IP }}
|
|
#sshpass -p "${PASS_NORMAL}" ssh-copy-id -i ~/.ssh/id_rsa.pub -o "StrictHostKeyChecking=accept-new" guest@${{ env.DUT_IP }}
|
|
|
|
- name: Read Linux family
|
|
timeout-minutes: 25
|
|
if: ${{ github.repository_owner == 'Armbian' && env.STATUS == '' }}
|
|
run: |
|
|
|
|
echo "LINUXFAMILY=$(timeout 20 ssh -o StrictHostKeyChecking=no root@${{ env.DUT_IP }} "cat /etc/armbian-release | grep LINUXFAMILY | cut -d"=" -f2" || true)" >> $GITHUB_ENV
|
|
rm -rf *.json
|
|
|
|
- name: Install beta legacy kernel on DUT
|
|
if: ${{ github.repository_owner == 'Armbian' && contains(env.KERNEL_TARGET, 'legacy') }}
|
|
timeout-minutes: 30
|
|
uses: armbian/actions/dut-run@main
|
|
with:
|
|
DUT_IP: "${{ env.DUT_IP }}"
|
|
DUT_SLUG: "${{ env.DUT_SLUG }}"
|
|
DUT_CONF_TYPE: "${{ env.DUT_CONF_TYPE }}"
|
|
STATUS: "${{ env.STATUS }}"
|
|
BOARD_NAME: "${{ env.BOARD_NAME }}"
|
|
BRANCH: "legacy"
|
|
REPOSITORY: "beta.armbian.com"
|
|
LINUXFAMILY: "${{ env.LINUXFAMILY }}"
|
|
|
|
- name: Install stable legacy kernel on DUT
|
|
if: ${{ github.repository_owner == 'Armbian' && contains(env.KERNEL_TARGET, 'legacy') && inputs.BETAONLY != 'true' }}
|
|
timeout-minutes: 30
|
|
uses: armbian/actions/dut-run@main
|
|
with:
|
|
DUT_IP: "${{ env.DUT_IP }}"
|
|
DUT_SLUG: "${{ env.DUT_SLUG }}"
|
|
DUT_CONF_TYPE: "${{ env.DUT_CONF_TYPE }}"
|
|
STATUS: "${{ env.STATUS }}"
|
|
BOARD_NAME: "${{ env.BOARD_NAME }}"
|
|
BRANCH: "legacy"
|
|
REPOSITORY: "apt.armbian.com"
|
|
LINUXFAMILY: "${{ env.LINUXFAMILY }}"
|
|
|
|
- name: Install beta vendor kernel on DUT
|
|
if: ${{ github.repository_owner == 'Armbian' && contains(env.KERNEL_TARGET, 'vendor') }}
|
|
timeout-minutes: 30
|
|
uses: armbian/actions/dut-run@main
|
|
with:
|
|
DUT_IP: "${{ env.DUT_IP }}"
|
|
DUT_SLUG: "${{ env.DUT_SLUG }}"
|
|
DUT_CONF_TYPE: "${{ env.DUT_CONF_TYPE }}"
|
|
STATUS: "${{ env.STATUS }}"
|
|
BOARD_NAME: "${{ env.BOARD_NAME }}"
|
|
BRANCH: "vendor"
|
|
REPOSITORY: "beta.armbian.com"
|
|
LINUXFAMILY: "${{ env.LINUXFAMILY }}"
|
|
|
|
- name: Install stable vendor kernel on DUT
|
|
if: ${{ github.repository_owner == 'Armbian' && contains(env.KERNEL_TARGET, 'vendor') && inputs.BETAONLY != 'true' }}
|
|
timeout-minutes: 30
|
|
uses: armbian/actions/dut-run@main
|
|
with:
|
|
DUT_IP: "${{ env.DUT_IP }}"
|
|
DUT_SLUG: "${{ env.DUT_SLUG }}"
|
|
DUT_CONF_TYPE: "${{ env.DUT_CONF_TYPE }}"
|
|
STATUS: "${{ env.STATUS }}"
|
|
BOARD_NAME: "${{ env.BOARD_NAME }}"
|
|
BRANCH: "vendor"
|
|
REPOSITORY: "apt.armbian.com"
|
|
LINUXFAMILY: "${{ env.LINUXFAMILY }}"
|
|
|
|
- name: Install beta current kernel on DUT
|
|
if: ${{ github.repository_owner == 'Armbian' && contains(env.KERNEL_TARGET, 'current') }}
|
|
timeout-minutes: 30
|
|
uses: armbian/actions/dut-run@main
|
|
with:
|
|
DUT_IP: "${{ env.DUT_IP }}"
|
|
DUT_SLUG: "${{ env.DUT_SLUG }}"
|
|
DUT_CONF_TYPE: "${{ env.DUT_CONF_TYPE }}"
|
|
STATUS: "${{ env.STATUS }}"
|
|
BOARD_NAME: "${{ env.BOARD_NAME }}"
|
|
BRANCH: "current"
|
|
REPOSITORY: "beta.armbian.com"
|
|
LINUXFAMILY: "${{ env.LINUXFAMILY }}"
|
|
|
|
- name: Install stable current kernel on DUT
|
|
if: ${{ github.repository_owner == 'Armbian' && contains(env.KERNEL_TARGET, 'current') && inputs.BETAONLY != 'true' }}
|
|
timeout-minutes: 30
|
|
uses: armbian/actions/dut-run@main
|
|
with:
|
|
DUT_IP: "${{ env.DUT_IP }}"
|
|
DUT_SLUG: "${{ env.DUT_SLUG }}"
|
|
DUT_CONF_TYPE: "${{ env.DUT_CONF_TYPE }}"
|
|
STATUS: "${{ env.STATUS }}"
|
|
BOARD_NAME: "${{ env.BOARD_NAME }}"
|
|
BRANCH: "current"
|
|
REPOSITORY: "apt.armbian.com"
|
|
LINUXFAMILY: "${{ env.LINUXFAMILY }}"
|
|
|
|
- name: Install beta edge kernel on DUT
|
|
if: ${{ github.repository_owner == 'Armbian' && contains(env.KERNEL_TARGET, 'edge') }}
|
|
timeout-minutes: 30
|
|
uses: armbian/actions/dut-run@main
|
|
with:
|
|
DUT_IP: "${{ env.DUT_IP }}"
|
|
DUT_SLUG: "${{ env.DUT_SLUG }}"
|
|
DUT_CONF_TYPE: "${{ env.DUT_CONF_TYPE }}"
|
|
STATUS: "${{ env.STATUS }}"
|
|
BOARD_NAME: "${{ env.BOARD_NAME }}"
|
|
BRANCH: "edge"
|
|
REPOSITORY: "beta.armbian.com"
|
|
LINUXFAMILY: "${{ env.LINUXFAMILY }}"
|
|
|
|
- name: Install stable edge kernel on DUT
|
|
if: ${{ github.repository_owner == 'Armbian' && contains(env.KERNEL_TARGET, 'edge') && inputs.BETAONLY != 'true' }}
|
|
timeout-minutes: 30
|
|
uses: armbian/actions/dut-run@main
|
|
with:
|
|
DUT_IP: "${{ env.DUT_IP }}"
|
|
DUT_SLUG: "${{ env.DUT_SLUG }}"
|
|
DUT_CONF_TYPE: "${{ env.DUT_CONF_TYPE }}"
|
|
STATUS: "${{ env.STATUS }}"
|
|
BOARD_NAME: "${{ env.BOARD_NAME }}"
|
|
BRANCH: "edge"
|
|
REPOSITORY: "apt.armbian.com"
|
|
LINUXFAMILY: "${{ env.LINUXFAMILY }}"
|
|
|
|
Stop:
|
|
name: "Merge artifacts"
|
|
if: always()
|
|
needs: Test
|
|
runs-on: [self-hosted, Linux, local]
|
|
steps:
|
|
|
|
- name: "Runner clean"
|
|
uses: armbian/actions/runner-clean@main
|
|
|
|
- name: "Download changes"
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: JSON
|
|
|
|
- name: "Delete artifact"
|
|
uses: geekyeggo/delete-artifact@v2
|
|
with:
|
|
name: JSON
|
|
|
|
- name: "Merge JSON parts"
|
|
run: |
|
|
cat <<- EOF > merged.json
|
|
[
|
|
{
|
|
"started" : "<b>Started</b>",
|
|
"status" : "",
|
|
"dut_ip" : "IP",
|
|
"board_name" : "<b>Board name</b>",
|
|
"board_slug" : "Board ID",
|
|
"board_conf_type": "<b>Support</b>",
|
|
"u-boot" : "U-boot",
|
|
"kernel" : "<b>Kernel version</b>",
|
|
"iperf" : "<b>Iperf</b>",
|
|
"sevenzip" : "<b>7z -b</b>",
|
|
"armbian_monitor" : "<b>Logs</b>",
|
|
"kernel_target" : "<b>Branch</b>",
|
|
"repository" : "<b>Repo</b>"
|
|
},
|
|
EOF
|
|
cat ./*.parts | sed '$ s/.$//' >> merged.json
|
|
echo "]" >> merged.json
|
|
|
|
- name: "Upload JSON"
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: status
|
|
path: merged.json
|
|
|
|
|
|
- name: Read/Write data into README
|
|
uses: eddiejaoude/github-actions-reader-writer@v0.1
|
|
with:
|
|
json-file-path: 'merged.json'
|
|
github-token: ${{ secrets.ACCESS_TOKEN_ARMBIANWORKER }}
|
|
columns: 1
|
|
object-field-names: '[ "started", "board_name", "board_slug", "board_slug", "board_conf_type", "u-boot", "kernel" , "iperf" , "sevenzip" , "armbian_monitor", "kernel_target", "repository" ]'
|
|
html-cell: '<td align="left"><a id={{ board_slug }} href=#{{ board_slug }}>{{ board_name }}</a></td><td align=center>{{ kernel }}</td><td align=center>{{ board_conf_type }}</td><td align=left>{{ armbian_monitor }}</td><td align=right>{{ iperf }}</td><td align=right>{{ sevenzip }}</td><td align=right>{{ repository }}</td>'
|
|
|
|
- name: Power off
|
|
if: ${{ inputs.PWRMNGMT == 'true' }}
|
|
uses: armbian/actions/power-off@main
|
|
with:
|
|
|
|
KEY_POWER_OFF: ${{ secrets.KEY_POWER_OFF }}
|
|
USER_REPOSITORY: ${{ secrets.USER_REPOSITORY }}
|
|
HOST_REPOSITORY: ${{ secrets.HOST_REPOSITORY }}
|
|
KNOWN_HOSTS_REPOSITORY: ${{ secrets.KNOWN_HOSTS_REPOSITORY }}
|