forked from alt/image-forge
Compare commits
1 Commits
master
...
test_workf
Author | SHA1 | Date | |
---|---|---|---|
4e751c4b6e |
@ -3,13 +3,43 @@ on:
|
|||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- '*_*/*_*'
|
- '*_*/*_*'
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
branch:
|
||||||
|
description: "Repository branch"
|
||||||
|
required: true
|
||||||
|
default: sisyphus
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- sisyphus
|
||||||
|
- p11
|
||||||
|
- p10
|
||||||
|
- c10f2
|
||||||
|
organization:
|
||||||
|
description: "Group of images"
|
||||||
|
required: true
|
||||||
|
default: alt
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- alt
|
||||||
|
- base
|
||||||
|
- k8s
|
||||||
|
- kubevirt
|
||||||
|
image:
|
||||||
|
description: "Image name"
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
version:
|
||||||
|
description: "Package version"
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-process:
|
build-process:
|
||||||
runs-on: alt-sisyphus
|
runs-on: alt-sisyphus
|
||||||
outputs:
|
outputs:
|
||||||
branch: ${{ env.BRANCH }}
|
branch: ${{ inputs.branch }}
|
||||||
image: ${{ env.IMAGE }}
|
image: ${{ inputs.image }}
|
||||||
url: ${{ env.URL }}
|
url: ${{ env.URL }}
|
||||||
repo: ${{ env.REPO }}
|
repo: ${{ env.REPO }}
|
||||||
buildres: ${{ steps.build-script.outcome }}
|
buildres: ${{ steps.build-script.outcome }}
|
||||||
@ -21,7 +51,7 @@ jobs:
|
|||||||
echo "URL=$repourl" >> ${GITHUB_ENV}
|
echo "URL=$repourl" >> ${GITHUB_ENV}
|
||||||
echo "URL=$repourl"
|
echo "URL=$repourl"
|
||||||
reponame=$(echo $GR | cut -d '/' -f 1)
|
reponame=$(echo $GR | cut -d '/' -f 1)
|
||||||
echo "REPO=$reponame" >> ${GITHUB_ENV}
|
echo "REPO=$reponame" >> ${GITHUB_ENV}
|
||||||
echo "REPO=$reponame"
|
echo "REPO=$reponame"
|
||||||
env:
|
env:
|
||||||
GU: ${{ gitea.server_url }}
|
GU: ${{ gitea.server_url }}
|
||||||
@ -29,7 +59,7 @@ jobs:
|
|||||||
- name: Set repo for c10f2 (Temporary)
|
- name: Set repo for c10f2 (Temporary)
|
||||||
if: ${{ contains(github.ref_name, 'c10f2') }}
|
if: ${{ contains(github.ref_name, 'c10f2') }}
|
||||||
run: |
|
run: |
|
||||||
echo "event tag=${{ github.ref_name }}"
|
echo "event tag=${{ github.ref_name }}"
|
||||||
echo "10.4.0.3 update.altsp.su" >> /etc/hosts
|
echo "10.4.0.3 update.altsp.su" >> /etc/hosts
|
||||||
echo "cat /etc/hosts"
|
echo "cat /etc/hosts"
|
||||||
cat /etc/hosts
|
cat /etc/hosts
|
||||||
@ -46,121 +76,96 @@ jobs:
|
|||||||
- name: Login podman gitea
|
- name: Login podman gitea
|
||||||
run: |
|
run: |
|
||||||
echo "podman login ${{ env.URL }}"
|
echo "podman login ${{ env.URL }}"
|
||||||
podman login --username $P_USER --password $P_PASS ${{ env.URL }}
|
podman login --username $P_USER --password $P_PASS ${{ env.URL }}
|
||||||
env:
|
env:
|
||||||
P_USER: ${{ secrets.PODMAN_USER }}
|
P_USER: ${{ secrets.PODMAN_USER }}
|
||||||
P_PASS: ${{ secrets.PODMAN_PASS }}
|
P_PASS: ${{ secrets.PODMAN_PASS }}
|
||||||
- name: Check files in the repository
|
- name: Check files in the repository
|
||||||
run: |
|
run: |
|
||||||
ls -a ${{ gitea.workspace }}
|
ls -a ${{ gitea.workspace }}
|
||||||
- name: Parse target branch and tag from events context, save to env
|
|
||||||
env:
|
|
||||||
EV: ${{ toJson(gitea.event) }}
|
|
||||||
run: |
|
|
||||||
echo $EV | jq '.ref' -r | sed "s/refs\/tags\//BRANCH=/g" | cut -d '_' -f 1
|
|
||||||
echo $EV | jq '.ref' -r | sed "s/refs\/tags\//BRANCH=/g" | cut -d '_' -f 1 >> ${GITHUB_ENV}
|
|
||||||
localimage=$(echo $EV | jq '.ref' -r | sed 's/refs\/tags\///g' | cut -d '_' -f 2)
|
|
||||||
echo "IMAGE=$localimage" >> ${GITHUB_ENV}
|
|
||||||
echo "IMAGE=$localimage"
|
|
||||||
org=$(echo "$localimage" | cut -d '/' -f 1)
|
|
||||||
echo "ORG=$org" >> ${GITHUB_ENV}
|
|
||||||
echo "ORG=$org"
|
|
||||||
ver=$(echo $EV | jq '.ref' -r | sed 's/refs\/tags\///g' | cut -d '_' -f 3)
|
|
||||||
echo "VER=$ver" >> ${GITHUB_ENV}
|
|
||||||
echo "VER=$ver"
|
|
||||||
- name: Get test for image
|
- name: Get test for image
|
||||||
run: |
|
run: |
|
||||||
if test -f ${{ gitea.workspace }}/org/$IM/test; then testscript=$(cat ${{ gitea.workspace }}/org/$IM/test); else testscript=""; fi
|
if test -f ${{ gitea.workspace }}/org/$IM/test; then testscript=$(cat ${{ gitea.workspace }}/org/$IM/test); else testscript=""; fi
|
||||||
echo "TEST=$testscript" >> ${GITHUB_ENV}
|
echo "TEST=$testscript" >> ${GITHUB_ENV}
|
||||||
env:
|
env:
|
||||||
IM: ${{ env.IMAGE }}
|
IM: ${{ inputs.organization }}/${{ inputs.image }}
|
||||||
BR: ${{ env.BRANCH }}
|
BR: ${{ inputs.branch }}
|
||||||
- name: Run building script
|
- name: Run building script
|
||||||
id: build-script
|
id: build-script
|
||||||
run: |
|
run: |
|
||||||
if [[ "$IM" == *"k8s"* ]]; then k8sarg="--package-versions {\"$IM\":\"$VER\"}"; else k8sarg=""; fi
|
if [[ "$IM" == *"k8s"* ]]; then k8sarg="--package-versions {\"$IM\":\"$VER\"}"; else k8sarg=""; fi
|
||||||
if [[ "$BR" == "sisyphus" ]]; then arches="--arches amd64 386 arm64 loong64"; else arches="--arches amd64 386 arm64"; fi
|
if [[ "$BR" == "sisyphus" ]]; then arches="--arches amd64 386 arm64 loong64"; else arches="--arches amd64 386 arm64"; fi
|
||||||
echo "build.py -i $IM -b $BR $arches $k8sarg"
|
echo "build.py -i $IM -b $BR $arches $k8sarg"
|
||||||
${{ gitea.workspace }}/build.py -i $IM -b $BR $arches --latest $BR --log-level debug --registry gitea.basealt.ru/alt $k8sarg
|
${{ gitea.workspace }}/build.py --skip-stages push -i $IM -b $BR $arches --latest $BR --log-level debug --registry gitea.basealt.ru/alt $k8sarg
|
||||||
env:
|
env:
|
||||||
IM: ${{ env.IMAGE }}
|
IM: ${{ inputs.organization }}/${{ inputs.image }}
|
||||||
VER: ${{ env.VER }}
|
VER: ${{ inputs.version }}
|
||||||
BR: ${{ env.BRANCH }}
|
BR: ${{ inputs.branch }}
|
||||||
ORG: ${{ env.ORG }}
|
ORG: ${{ inputs.organization }}
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
- name: Send notification if build crashed
|
# - name: Send notification if build crashed
|
||||||
if: ${{ steps.build-script.outcome != 'success' }}
|
# if: ${{ steps.build-script.outcome != 'success' }}
|
||||||
run: |
|
# run: |
|
||||||
issueid=1
|
# issueid=1
|
||||||
body="Building image $IM finish with some errors."
|
# body="Building image $IM finish with some errors."
|
||||||
curl -X 'POST' "$URL/api/v1/repos/$REPO/image-forge/issues/$issueid/comments?token=$T" -H 'accept: application/json' -H 'Content-Type: application/json' -d "{ \"body\": \"$body\" }" -s
|
# curl -X 'POST' "$URL/api/v1/repos/$REPO/image-forge/issues/$issueid/comments?token=$T" -H 'accept: application/json' -H 'Content-Type: application/json' -d "{ \"body\": \"$body\" }" -s
|
||||||
echo "notification about test error is sent to issue $issueid"
|
# echo "notification about test error is sent to issue $issueid"
|
||||||
env:
|
# env:
|
||||||
T: ${{ secrets.TOKEN }}
|
# T: ${{ secrets.TOKEN }}
|
||||||
BR: ${{ env.BRANCH }}
|
# BR: ${{ inputs.branch }}
|
||||||
URL: ${{ gitea.server_url }}
|
# URL: ${{ gitea.server_url }}
|
||||||
REPO: ${{ env.REPO }}
|
# REPO: ${{ env.REPO }}
|
||||||
IM: ${{ env.IMAGE }}
|
# IM: ${{ inputs.organization }}/${{ inputs.image }}
|
||||||
- name: Delete event tag
|
# EV: ${{ toJson(gitea.event) }}
|
||||||
run: |
|
# test-process:
|
||||||
tagname=$(echo $EV | jq '.ref' -r | sed "s/refs\/tags\///g")
|
# needs: build-process
|
||||||
curl -X 'DELETE' "$URL/api/v1/repos/$REPO/image-forge/tags/$tagname?token=$T" -H 'accept: application/json' -s
|
# if: ${{ needs.build-process.outputs.buildres == 'success' }}
|
||||||
echo "tag $tagname is deleted"
|
# runs-on: alt-sisyphus
|
||||||
env:
|
# steps:
|
||||||
T: ${{ secrets.TOKEN }}
|
# - name: Update apt
|
||||||
BR: ${{ env.BRANCH }}
|
# uses: https://gitea.basealt.ru/actions/init-alt-env@v1
|
||||||
URL: ${{ gitea.server_url }}
|
# - name: Install requires
|
||||||
REPO: ${{ env.REPO }}
|
# run: |
|
||||||
EV: ${{ toJson(gitea.event) }}
|
# echo "apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah curl"
|
||||||
test-process:
|
# apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah curl
|
||||||
needs: build-process
|
# - name: Run test
|
||||||
if: ${{ needs.build-process.outputs.buildres == 'success' }}
|
# id: test-script
|
||||||
runs-on: alt-sisyphus
|
# if: ${{ needs.build-process.outputs.test != '' }}
|
||||||
steps:
|
# continue-on-error: true
|
||||||
- name: Update apt
|
# run: |
|
||||||
uses: https://gitea.basealt.ru/actions/init-alt-env@v1
|
# imname=$(echo "$IM" | cut -d "/" -f2)
|
||||||
- name: Install requires
|
# if [[ "$IM" == *"k8s"* ]]; then echo "skip tests for k8s images"; else podman run --rm --entrypoint="/bin/sh" $URL/$REPO/$BR/$imname:latest -c "$TEST"; fi
|
||||||
run: |
|
# env:
|
||||||
echo "apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah curl"
|
# IM: ${{ needs.build-process.outputs.image }}
|
||||||
apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah curl
|
# BR: ${{ needs.build-process.outputs.branch }}
|
||||||
- name: Run test
|
# URL: ${{ needs.build-process.outputs.url }}
|
||||||
id: test-script
|
# REPO: ${{ needs.build-process.outputs.repo }}
|
||||||
if: ${{ needs.build-process.outputs.test != '' }}
|
# TEST: ${{ needs.build-process.outputs.test }}
|
||||||
continue-on-error: true
|
# - name: Run special test
|
||||||
run: |
|
# id: special-test
|
||||||
imname=$(echo "$IM" | cut -d "/" -f2)
|
# if: ${{ needs.build-process.outputs.test == '' }}
|
||||||
if [[ "$IM" == *"k8s"* ]]; then echo "skip tests for k8s images"; else podman run --rm --entrypoint="/bin/sh" $URL/$REPO/$BR/$imname:latest -c "$TEST"; fi
|
# continue-on-error: true
|
||||||
env:
|
# run: |
|
||||||
IM: ${{ needs.build-process.outputs.image }}
|
# imname=$(echo "$IM" | cut -d "/" -f2)
|
||||||
BR: ${{ needs.build-process.outputs.branch }}
|
# if [[ $IM = 'alt/distroless-true' ]]; then podman run --rm $URL/$REPO/$BR/$imname:latest true; fi
|
||||||
URL: ${{ needs.build-process.outputs.url }}
|
# if [[ $IM = 'alt/distroless-gotop' ]]; then podman run --rm $URL/$REPO/$BR/$imname:latest --version; fi
|
||||||
REPO: ${{ needs.build-process.outputs.repo }}
|
# env:
|
||||||
TEST: ${{ needs.build-process.outputs.test }}
|
# IM: ${{ needs.build-process.outputs.image }}
|
||||||
- name: Run special test
|
# BR: ${{ needs.build-process.outputs.branch }}
|
||||||
id: special-test
|
# URL: ${{ needs.build-process.outputs.url }}
|
||||||
if: ${{ needs.build-process.outputs.test == '' }}
|
# REPO: ${{ needs.build-process.outputs.repo }}
|
||||||
continue-on-error: true
|
# - name: Send notification if test crashed
|
||||||
run: |
|
# if: ${{ steps.test-script.outcome == 'failure' || steps.special-test.outcome == 'failure' }}
|
||||||
imname=$(echo "$IM" | cut -d "/" -f2)
|
# run: |
|
||||||
if [[ $IM = 'alt/distroless-true' ]]; then podman run --rm $URL/$REPO/$BR/$imname:latest true; fi
|
# issueid=1
|
||||||
if [[ $IM = 'alt/distroless-gotop' ]]; then podman run --rm $URL/$REPO/$BR/$imname:latest --version; fi
|
# errors=$(cat errors.log)
|
||||||
env:
|
# body="Testing image $IM finish with some errors."
|
||||||
IM: ${{ needs.build-process.outputs.image }}
|
# curl -X 'POST' "$URL/api/v1/repos/$REPO/image-forge/issues/$issueid/comments?token=$T" -H 'accept: application/json' -H 'Content-Type: application/json' -d "{ \"body\": \"$body\" }" -s
|
||||||
BR: ${{ needs.build-process.outputs.branch }}
|
# echo "notification about test error is sent to issue $issueid"
|
||||||
URL: ${{ needs.build-process.outputs.url }}
|
# env:
|
||||||
REPO: ${{ needs.build-process.outputs.repo }}
|
# T: ${{ secrets.TOKEN }}
|
||||||
- name: Send notification if test crashed
|
# BR: ${{ needs.build-process.outputs.branch }}
|
||||||
if: ${{ steps.test-script.outcome == 'failure' || steps.special-test.outcome == 'failure' }}
|
# URL: ${{ gitea.server_url }}
|
||||||
run: |
|
# REPO: ${{ needs.build-process.outputs.repo }}
|
||||||
issueid=1
|
# IM: ${{ needs.build-process.outputs.image }}
|
||||||
errors=$(cat errors.log)
|
#
|
||||||
body="Testing image $IM finish with some errors."
|
|
||||||
curl -X 'POST' "$URL/api/v1/repos/$REPO/image-forge/issues/$issueid/comments?token=$T" -H 'accept: application/json' -H 'Content-Type: application/json' -d "{ \"body\": \"$body\" }" -s
|
|
||||||
echo "notification about test error is sent to issue $issueid"
|
|
||||||
env:
|
|
||||||
T: ${{ secrets.TOKEN }}
|
|
||||||
BR: ${{ needs.build-process.outputs.branch }}
|
|
||||||
URL: ${{ gitea.server_url }}
|
|
||||||
REPO: ${{ needs.build-process.outputs.repo }}
|
|
||||||
IM: ${{ needs.build-process.outputs.image }}
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user