23 Commits

Author SHA1 Message Date
70ab7aa80d test creating package event 2024-09-27 18:33:08 +03:00
53148b13e9 add o=publish script, add rework to full wf 2024-09-27 16:55:49 +03:00
17619fe844 fix from-path in dockerfiles
All checks were successful
Full building alt images / build-process (push) Successful in 9m41s
Full building alt images / test-process (push) Successful in 4m16s
2024-05-24 17:28:59 +03:00
1b60aaab69 Обновить org/other/apache2/Dockerfile.template 2024-05-24 17:01:04 +03:00
24c0f309a8 Обновить org/other/apache2/Dockerfile.template 2024-05-24 17:00:07 +03:00
00e92ce73c Обновить org/other/python/Dockerfile.template 2024-05-24 16:59:07 +03:00
92afc86488 Обновить .gitea/workflows/testscript
All checks were successful
Full building alt images / build-process (push) Successful in 4m25s
Full building alt images / test-process (push) Has been skipped
2024-05-24 15:31:15 +03:00
425544a9e2 Обновить .gitea/workflows/testscript
All checks were successful
Full building alt images / build-process (push) Successful in 11m27s
Full building alt images / test-process (push) Successful in 3m8s
2024-05-24 14:21:15 +03:00
b7b8c1cc43 Обновить .gitea/workflows/testscript
All checks were successful
Full building alt images / build-process (push) Successful in 11m25s
Full building alt images / test-process (push) Successful in 2m58s
2024-05-24 13:57:40 +03:00
fe5505f5bb Обновить .gitea/workflows/testscript
All checks were successful
Full building alt images / build-process (push) Successful in 11m41s
Full building alt images / test-process (push) Successful in 2m55s
2024-05-24 13:26:07 +03:00
c09ac19197 Обновить .gitea/workflows/testscript
All checks were successful
Full building alt images / build-process (push) Successful in 11m21s
Full building alt images / test-process (push) Successful in 1m50s
2024-05-24 13:05:47 +03:00
3fd7e42cf1 Обновить .gitea/workflows/wf_full_p10.yaml 2024-05-24 13:04:13 +03:00
03978ae7ca Обновить .gitea/workflows/testscript
All checks were successful
Full building alt images / build-process (push) Successful in 11m18s
Full building alt images / test-process (push) Successful in 1m36s
2024-05-24 12:26:08 +03:00
05bda1c7a6 Обновить .gitea/workflows/wf_full_p10.yaml
Some checks failed
Full building alt images / build-process (push) Successful in 11m24s
Full building alt images / test-process (push) Failing after 1m37s
2024-05-24 11:39:01 +03:00
aac8445456 Обновить .gitea/workflows/wf_full_p10.yaml
All checks were successful
Full building alt images / build-process (push) Successful in 1m50s
Full building alt images / test-process (push) Has been skipped
2024-05-24 11:10:22 +03:00
556ee2952c Обновить .gitea/workflows/testscript 2024-05-23 18:41:06 +03:00
795c9cdd5f Обновить .gitea/workflows/testscript
Some checks failed
Full building alt images / build-process (push) Successful in 53m27s
Full building alt images / test-process (push) Failing after 1m39s
2024-05-23 16:20:27 +03:00
c6819fad58 Обновить .gitea/workflows/testscript 2024-05-23 16:18:52 +03:00
b7aeed6996 Обновить .gitea/workflows/wf_full_p10.yaml 2024-05-23 16:14:09 +03:00
775f388990 Обновить .gitea/workflows/wf_full_p10.yaml
All checks were successful
Full building alt images / build-process (push) Successful in 1m52s
Full building alt images / test-process (push) Has been skipped
2024-05-23 15:59:23 +03:00
ebc3a8886b Обновить .gitea/workflows/wf_full_p10.yaml 2024-05-23 15:57:54 +03:00
42cd5492ad Обновить build.py
All checks were successful
Full building alt images / build-process (push) Successful in 2m20s
Full building alt images / test-process (push) Has been skipped
2024-05-23 15:44:35 +03:00
8c4c43e20c Обновить .gitea/workflows/wf_full_p10.yaml 2024-05-23 15:21:17 +03:00
15 changed files with 124 additions and 34 deletions

View File

@ -0,0 +1,15 @@
name: Run tests wf
on:
registry_package:
types: [published, updated]
jobs:
build-process:
runs-on: alt-sisyphus
steps:
- name: Check event
run: |
echo "name package = ${{ github.event.registry_package.name }}"
echo "path package = ${{ github.event.registry_package.html_url }}"
echo "version package = ${{ github.event.registry_package.package_version.version }}"
echo "version package = ${{ github.event.registry_package.package_version.container_metadata.tag.name }}"

View File

@ -11,15 +11,16 @@ ORG=${2:-"base"}
URL=${3:-"gitea.basealt.ru"}
REPO=${4:-"alt"}
WS=${5:-"image-forge"}
wspath="/workspace/$REPO/$WS"
errors=''
haserr=false
for IM in $(ls $WS/org/$ORG/ | xargs)
for IM in $(ls $wspath/org/$ORG/ | xargs)
do
echo "image=$IM"
imgpath="$REPO/$WS/$BR/$IM:$BR"
imgpath="$REPO/$BR/$ORG/$IM:$BR"
command=''
testpath="$WS/org/$ORG/$IM/test.yaml"
testpath="$wspath/org/$ORG/$IM/test.yaml"
if test -f $testpath
then
entrypoint=''
@ -41,21 +42,22 @@ do
echo "start change tag for $IM"
if [[ $ORG != 'base' ]]
then
package=$(podman images --filter reference=$URL/$imgpath --format='{{ json .Labels }}' | jq '."org.opencontainers.image.title"' -r 2> /dev/null)
package=$(podman images --filter reference=$URL/$imgpath --format='{{ json .Labels }}' | jq '."org.opencontainers.image.title"' -r 2> /dev/null)
if [[ $package != '' ]]
then
tag=$(podman run --rm --entrypoint="/bin/sh" $URL/$imgpath -c "rpm -qa --qf \"%{VERSION}\n\" $package" 2> /dev/null)
else
echo "not found package name in images labels"
fi
else
then tag=$(date +"%Y%m%d")
tag=$(podman run --rm --entrypoint="/bin/sh" $URL/$imgpath -c "rpm -qa --qf \"%{VERSION}\n\" $package" 2> /dev/null)
else
echo "not found package name in images labels"
fi
else tag=$(date +"%Y%m%d")
fi
if [[ $tag != '' ]]
then
skopeo copy -a docker://$URL/$imgpath:$BR docker://$URL/$imgpath:$tag
scopeo delete docker://$URL/$imgpath:$BR
echo "newtag=$tag"
newimgpath="$REPO/$BR/$ORG/$IM:$tag"
skopeo copy -a docker://$URL/$imgpath docker://$URL/$newimgpath
#skopeo delete docker://$URL/$imgpath
echo "tag is updated"
else echo "new tag is empty and is not sent to repository"
fi
@ -70,7 +72,6 @@ do
echo "podman rmi --all"
podman rmi --all
fi
haserr=false
done

View File

@ -15,6 +15,7 @@ jobs:
org: ${{ env.ORG }}
url: ${{ env.URL }}
repo: ${{ env.REPO }}
ws: ${{ env.WS }}
buildres: ${{ steps.build-script.outcome }}
steps:
- name: Check workspace
@ -25,6 +26,9 @@ jobs:
reponame=$(echo $GR | cut -d '/' -f 1)
echo "REPO=$reponame" >> ${GITHUB_ENV}
echo $reponame
repows=$(echo $GR | cut -d '/' -f 2)
echo "WS=$repows" >> ${GITHUB_ENV}
echo $repows
env:
GU: ${{ gitea.server_url }}
GR: ${{ gitea.repository }}
@ -64,52 +68,57 @@ jobs:
- name: Run standart building script
id: build-script
run: |
build_args="-b $BR -o $ORG --skip-images base/distroless-devel --overwrite-organization $BR --registry $URL/${{ gitea.workspace }}/$BR"
build_args="-b $BR -o $ORG --skip-images base/distroless-devel --registry $URL/$REPO/$BR -a amd64"
echo "build.py $build_args"
${{ gitea.workspace }}/build.py $build_args
env:
ORG: ${{ env.ORG }}
BR: ${{ env.BRANCH }}
REPO: ${{ env.REPO }}
continue-on-error: true
- name: Send notification if build crashed
if: ${{ steps.build-script.outcome != 'success' }}
run: |
issueid=1
body="Building images 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/$GWS/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: ${{ env.BRANCH }}
URL: ${{ gitea.server_url }}
REPO: ${{ env.REPO }}
GWS: ${{ env.WS }}
- name: Delete event tag
run: |
tagname=$(echo $EV | jq '.ref' -r | sed "s/refs\/tags\///g")
curl -X 'DELETE' "$URL/api/v1/repos/$REPO/image-forge/tags/$tagname?token=$T" -H 'accept: application/json' -s
curl -X 'DELETE' "$URL/api/v1/repos/$REPO/$GWS/tags/$tagname?token=$T" -H 'accept: application/json' -s
echo "tag $tagname is deleted"
env:
T: ${{ secrets.TOKEN }}
BR: ${{ env.BRANCH }}
URL: ${{ gitea.server_url }}
REPO: ${{ env.REPO }}
GWS: ${{ env.WS }}
EV: ${{ toJson(gitea.event) }}
test-process:
needs: build-process
if: ${{ needs.build-process.outputs.buildres == 'success' }}
runs-on: alt-p10
outputs:
testres: ${{ steps.test-script.outcome }}
steps:
- name: Update apt
uses: actions/init-alt-env@v1
- name: Install requires
run: |
echo "apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah skopeo jq yq curl"
apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah jq curl
apt-get install -y python3-module-tomli python3-module-jinja2 podman buildah skopeo jq yq curl
- name: Check out current repo
uses: https://gitea.com/actions/checkout@v4
- name: Login podman gitea
run: |
echo "podman login ${{ env.URL }}"
echo "podman login ${{ needs.build-process.outputs.url }}"
podman login --username $P_USER --password $P_PASS ${{ needs.build-process.outputs.url }}
env:
P_USER: ${{ secrets.PODMAN_USER }}
@ -118,7 +127,7 @@ jobs:
id: test-script
continue-on-error: true
run: |
$WS/.gitea/workflows/testscript $BR $ORG $URL $REPO $WS
$WS/.gitea/workflows/testscript $BR $ORG $URL $REPO $GWS
cat haserr.log >> ${GITHUB_ENV}
echo "test process finished"
env:
@ -127,16 +136,60 @@ jobs:
URL: ${{ needs.build-process.outputs.url }}
REPO: ${{ needs.build-process.outputs.repo }}
WS: ${{ gitea.workspace }}
GWS: ${{ needs.build-process.outputs.ws }}
- name: Send notification if test crashed
if: ${{ env.ERR == 'true' || steps.test-script.outcome == 'failure' }}
run: |
issueid=1
errors=$(cat errors.log)
d errors=$(cat errors.log)
body="Testing images finish with some errors. $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/gitea-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 }}
push-process:
needs: [build-process, test-process]
if: ${{ needs.test-process.outputs.testres == 'success' && secrets.PUSH_REPO != '' }}
runs-on: alt-p10
steps:
- name: Update apt
uses: actions/init-alt-env@v1
- name: Install reqier-s
run: |
echo "apt-get install -y skopeo jq"
apt-get install -y skopeo jq
- name: Get branch and tags to push
run: |
echo "PUSH_BRANCH=$BR" >> ${GITHUB_ENV}
images=$()
echo "PUSH_IMAGES=$images" >> ${GITHUB_ENV}
if [[ $BR == 'p10' ]]; then echo "PUSH_TAGS=latest" >> ${GITHUB_ENV}; fi
env:
BR: ${{ needs.build-process.outputs.branch }}
- name: Get branch (only for c*N branches)
if: ${{ contains(github.ref_name, 'c10f2') }}
run: |
newbr=$(skopeo list-tags docker://$URL/$REPO/$BR/base/alt | jq '.Tags.[]' -r 2> /dev/null | sort | grep -m 1 c 2> /dev/null)
echo "PUSH_BRANCH=$newbr" >> ${GITHUB_ENV}
env:
BR: ${{ needs.build-process.outputs.branch }}
ORG: ${{ needs.build-process.outputs.org }}
URL: ${{ needs.build-process.outputs.url }}
REPO: ${{ needs.build-process.outputs.repo }}
- name: Run skopeo action
if: ${{ env.PUSH_BRANCH == needs.build-process.outputs.branch }}
uses: actions/skopeo-copy@v1
with:
source: ${{ needs.build-process.outputs.url }/${{ needs.build-process.outputs.repo }}/${{ needs.build-process.outputs.branch }}/${{ needs.build-process.outputs.org }}
source-proto: docker://
dest: ${{ secrets.PUSH_REPO }}/${{ needs.build-process.outputs.branch }}
dest-proto: docker://
dest-login: ${{ secrets.PUSH_USER }}
dest-pass: ${{ secrets.PUSH_PASS }}
tags: ${{ env.PUSH_TAGS }}
last-ver-tags: true
images: ${{ env.PUSH_IMAGES }}
args: -a

View File

@ -0,0 +1,21 @@
name: 'Reusable test job'
description: 'Test for images'
outputs:
result:
description: "Result of test (success|failure)"
value: ${{ jobs.example_job.outputs.output1 }}
inputs:
image: string
branch: string
url: string
repo: string
runs:
using: 'composite'
steps:
- name: Install requires
run: |
echo "apt-get install -y skopeo jq"
apt-get install -y skopeo jq
- name: Scopeo copy

View File

@ -230,7 +230,7 @@ class DockerBuilder:
) -> str:
if self.registry:
registry = self.registry.rstrip("/") + "/"
alt_image = "alt/alt"
alt_image = "base/alt"
else:
registry = ""
alt_image = "alt"
@ -307,7 +307,7 @@ class DockerBuilder:
f"{from_image['organization']}/{from_image['name']}"
)
elif distrolessfile.exists():
requires.add("alt/distroless-builder")
requires.add("base/distroless-builder")
raw_from = self.distrolesses[canonical_name].raw_from
from_ = self.render_template(raw_from, self.organization)
if match := re.match(self.image_re, from_):
@ -345,7 +345,7 @@ class DockerBuilder:
def distroless_build(self, image: Image, arches):
def distroless_build_arch(arch, manifest):
distroless_builder = self.render_full_tag(
Image("alt/distroless-builder"), self.branch
Image("base/distroless-builder"), self.branch
)
distroless = self.distrolesses[image.canonical_name]
distroless.render_arch_branch(arch, self.branch)

View File

@ -1,4 +1,4 @@
FROM {{ registry }}{{ organization }}/buildpack-deps-curl:{{ branch }}
FROM {{ registry }}base/buildpack-deps-curl:{{ branch }}
MAINTAINER alt-cloud

View File

@ -1,4 +1,4 @@
FROM {{ registry }}{{ organization }}/buildpack-deps-scm:{{ branch }}
FROM {{ registry }}base/buildpack-deps-scm:{{ branch }}
MAINTAINER alt-cloud

View File

@ -1,4 +1,4 @@
FROM {{ registry }}{{ organization }}/base:{{ branch }}
FROM {{ registry }}base/base:{{ branch }}
MAINTAINER alt-cloud

View File

@ -1,4 +1,4 @@
from = "{{ registry }}{{ organization }}/distroless-static:{{ branch }}"
from = "{{ registry }}base/distroless-static:{{ branch }}"
builder-install-packages = [
"glibc-core",
'{{if_branches(["p10"], "glibc-nss")}}',

View File

@ -1,4 +1,4 @@
from = "{{ registry }}{{ organization }}/distroless-base:{{ branch }}"
from = "{{ registry }}base/distroless-base:{{ branch }}"
builder-install-packages = [
"coreutils",
"findutils",

View File

@ -1,3 +1,3 @@
from = "{{ registry }}{{ organization }}/distroless-base:{{ branch }}"
from = "{{ registry }}base/distroless-base:{{ branch }}"
full-files = ["/usr/bin/gotop"]
entrypoint = ["/usr/bin/gotop"]

View File

@ -1,3 +1,3 @@
from = "{{ registry }}{{ organization }}/distroless-static:{{ branch }}"
from = "{{ registry }}base/distroless-static:{{ branch }}"
files = ["/bin/true"]
cmd = ["/bin/true"]

View File

@ -1,4 +1,4 @@
FROM {{ registry }}{{ organization }}/buildpack-deps:{{ branch }}
FROM {{ registry }}base/buildpack-deps:{{ branch }}
MAINTAINER alt-cloud

View File

@ -1,4 +1,4 @@
FROM {{ registry }}{{ organization }}/base:{{ branch }}
FROM {{ registry }}base/base:{{ branch }}
MAINTAINER alt-cloud

View File

@ -1,4 +1,4 @@
FROM {{ registry }}{{ organization }}/base:{{ branch }}
FROM {{ registry }}base/base:{{ branch }}
MAINTAINER alt-cloud