Skip to content

Commit fd01298

Browse files
author
Earl Warren
committed
Merge pull request '[RELEASE] build test releases' (go-gitea#2365) from earl-warren/forgejo:wip-test-release into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/2365
2 parents 0c0b87e + 3b9d39f commit fd01298

File tree

4 files changed

+103
-54
lines changed

4 files changed

+103
-54
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
FROM public.ecr.aws/docker/library/alpine:3.18
1+
FROM code.forgejo.org/oci/alpine:3.19
2+
ARG RELEASE_VERSION=unkown
23
RUN mkdir -p /app/gitea
3-
RUN ( echo '#!/bin/sh' ; echo "echo forgejo v1.2.3" ) > /app/gitea/gitea ; chmod +x /app/gitea/gitea
4+
RUN ( echo '#!/bin/sh' ; echo "echo forgejo v$RELEASE_VERSION" ) > /app/gitea/gitea ; chmod +x /app/gitea/gitea

.forgejo/workflows/build-release-integration.yml

Lines changed: 60 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ jobs:
3434
lxc-ip-prefix: 10.0.9
3535

3636
- name: publish the forgejo release
37+
shell: bash
3738
run: |
3839
set -x
3940
40-
version=1.2.3
4141
cat > /etc/docker/daemon.json <<EOF
4242
{
4343
"insecure-registries" : ["${{ steps.forgejo.outputs.host-port }}"]
@@ -53,6 +53,37 @@ jobs:
5353
url=http://root:admin1234@${{ steps.forgejo.outputs.host-port }}
5454
export FORGEJO_RUNNER_LOGS="${{ steps.forgejo.outputs.runner-logs }}"
5555
56+
function sanity_check() {
57+
local url=$1 version=$2
58+
#
59+
# Minimal sanity checks. Since the binary
60+
# is a script shell it does not test the sanity of the cross
61+
# build, only the sanity of the naming of the binaries.
62+
#
63+
for arch in amd64 arm64 arm-6 ; do
64+
local binary=forgejo-$version-linux-$arch
65+
for suffix in '' '.xz' ; do
66+
curl --fail -L -sS $url/root/forgejo/releases/download/v$version/$binary$suffix > $binary$suffix
67+
if test "$suffix" = .xz ; then
68+
unxz --keep $binary$suffix
69+
fi
70+
chmod +x $binary
71+
./$binary --version | grep $version
72+
curl --fail -L -sS $url/root/forgejo/releases/download/v$version/$binary$suffix.sha256 > $binary$suffix.sha256
73+
shasum -a 256 --check $binary$suffix.sha256
74+
rm $binary$suffix
75+
done
76+
done
77+
78+
local sources=forgejo-src-$version.tar.gz
79+
curl --fail -L -sS $url/root/forgejo/releases/download/v$version/$sources > $sources
80+
curl --fail -L -sS $url/root/forgejo/releases/download/v$version/$sources.sha256 > $sources.sha256
81+
shasum -a 256 --check $sources.sha256
82+
83+
docker pull ${{ steps.forgejo.outputs.host-port }}/root/forgejo:$version
84+
docker pull ${{ steps.forgejo.outputs.host-port }}/root/forgejo:$version-rootless
85+
}
86+
5687
#
5788
# Create a new project with a fake forgejo and the release workflow only
5889
#
@@ -62,46 +93,41 @@ jobs:
6293
cp $dir/Dockerfile $dir/Dockerfile.rootless
6394
6495
forgejo-test-helper.sh push $dir $url root forgejo
65-
sha=$(forgejo-test-helper.sh branch_tip $url root/forgejo main)
6696
67-
#
68-
# Push a tag to trigger the release workflow and wait for it to complete
69-
#
70-
forgejo-curl.sh api_json --data-raw '{"tag_name": "v'$version'", "target": "'$sha'"}' $url/api/v1/repos/root/forgejo/tags
7197
forgejo-curl.sh api_json -X PUT --data-raw '{"data":"${{ steps.forgejo.outputs.token }}"}' $url/api/v1/repos/root/forgejo/actions/secrets/TOKEN
7298
forgejo-curl.sh api_json -X PUT --data-raw '{"data":"root"}' $url/api/v1/repos/root/forgejo/actions/secrets/DOER
73-
LOOPS=180 forgejo-test-helper.sh wait_success "$url" root/forgejo $sha
99+
forgejo-curl.sh api_json -X PUT --data-raw '{"data":"true"}' $url/api/v1/repos/root/forgejo/actions/secrets/VERBOSE
74100
75101
#
76-
# uncomment to see the logs even when everything is reported to be working ok
102+
# Push a tag to trigger the release workflow and wait for it to complete
77103
#
78-
#cat $FORGEJO_RUNNER_LOGS
104+
version=1.2.3
105+
sha=$(forgejo-test-helper.sh branch_tip $url root/forgejo main)
106+
forgejo-curl.sh api_json --data-raw '{"tag_name": "v'$version'", "target": "'$sha'"}' $url/api/v1/repos/root/forgejo/tags
107+
LOOPS=180 forgejo-test-helper.sh wait_success "$url" root/forgejo $sha
108+
sanity_check $url $version
79109
80110
#
81-
# Minimal sanity checks. e2e test is for the setup-forgejo
82-
# action and the infrastructure playbook. Since the binary
83-
# is a script shell it does not test the sanity of the cross
84-
# build, only the sanity of the naming of the binaries.
111+
# Push a commit to a branch that triggers the build of a test release
85112
#
86-
for arch in amd64 arm64 arm-6 ; do
87-
binary=forgejo-$version-linux-$arch
88-
for suffix in '' '.xz' ; do
89-
curl --fail -L -sS $url/root/forgejo/releases/download/v$version/$binary$suffix > $binary$suffix
90-
if test "$suffix" = .xz ; then
91-
unxz --keep $binary$suffix
92-
fi
93-
chmod +x $binary
94-
./$binary --version | grep $version
95-
curl --fail -L -sS $url/root/forgejo/releases/download/v$version/$binary$suffix.sha256 > $binary$suffix.sha256
96-
shasum -a 256 --check $binary$suffix.sha256
97-
rm $binary$suffix
98-
done
99-
done
100-
101-
sources=forgejo-src-$version.tar.gz
102-
curl --fail -L -sS $url/root/forgejo/releases/download/v$version/$sources > $sources
103-
curl --fail -L -sS $url/root/forgejo/releases/download/v$version/$sources.sha256 > $sources.sha256
104-
shasum -a 256 --check $sources.sha256
113+
version=forgejo-test
114+
(
115+
git clone $url/root/forgejo /tmp/forgejo
116+
cd /tmp/forgejo
117+
date > DATE
118+
git config user.email [email protected]
119+
git config user.name username
120+
git add .
121+
git commit -m 'update'
122+
git push $url/root/forgejo main:forgejo
123+
)
124+
sha=$(forgejo-test-helper.sh branch_tip $url root/forgejo forgejo)
125+
LOOPS=180 forgejo-test-helper.sh wait_success "$url" root/forgejo $sha
126+
sanity_check $url $version
105127
106-
docker pull ${{ steps.forgejo.outputs.host-port }}/root/forgejo:$version
107-
docker pull ${{ steps.forgejo.outputs.host-port }}/root/forgejo:$version-rootless
128+
- name: full logs
129+
if: always()
130+
run: |
131+
sed -e 's/^/[RUNNER LOGS] /' ${{ steps.forgejo.outputs.runner-logs }}
132+
docker logs forgejo | sed -e 's/^/[FORGEJO LOGS]/'
133+
sleep 5 # hack to avoid mixing outputs in Forgejo v1.21

.forgejo/workflows/build-release.yml

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ name: Build release
1818

1919
on:
2020
push:
21-
tags: 'v*'
21+
tags: 'v[0-9]+.[0-9]+.*'
22+
branches:
23+
- 'forgejo'
24+
- 'v*/forgejo'
2225

2326
jobs:
2427
release:
@@ -43,17 +46,34 @@ jobs:
4346
go-version: "1.21"
4447
check-latest: true
4548

46-
- name: version from ref_name
47-
id: tag-version
49+
- name: version from ref
50+
id: release-info
51+
shell: bash
4852
run: |
49-
version="${{ github.ref_name }}"
50-
version=${version##*v}
51-
echo "value=$version" >> "$GITHUB_OUTPUT"
53+
set -x
54+
ref="${{ github.ref }}"
55+
if [[ $ref =~ ^refs/heads/ ]] ; then
56+
version=${ref#refs/heads/}
57+
version=${version%/forgejo}-test
58+
override=true
59+
fi
60+
if [[ $ref =~ ^refs/tags/ ]] ; then
61+
version=${ref#refs/tags/}
62+
override=false
63+
fi
64+
if test -z "$version" ; then
65+
echo failed to figure out the release version from the reference=$ref
66+
exit 1
67+
fi
68+
version=${version#v}
69+
echo "sha=${{ github.sha }}" >> "$GITHUB_OUTPUT"
70+
echo "version=$version" >> "$GITHUB_OUTPUT"
71+
echo "override=$override" >> "$GITHUB_OUTPUT"
5272
5373
- name: release notes
5474
id: release-notes
5575
run: |
56-
anchor=${{ steps.tag-version.outputs.value }}
76+
anchor=${{ steps.release-info.outputs.version }}
5777
anchor=${anchor//./-}
5878
cat >> "$GITHUB_OUTPUT" <<EOF
5979
value<<ENDVAR
@@ -65,7 +85,7 @@ jobs:
6585
run: |
6686
set -x
6787
apt-get -qq install -y make
68-
version=${{ steps.tag-version.outputs.value }}
88+
version=${{ steps.release-info.outputs.version }}
6989
#
7090
# Make sure all files are owned by the current user.
7191
# When run as root `npx webpack` will assume the identity
@@ -122,34 +142,38 @@ jobs:
122142
123143
- name: build container & release
124144
if: ${{ secrets.TOKEN != '' }}
125-
uses: https://code.forgejo.org/forgejo/forgejo-build-publish/build@v1
145+
uses: https://code.forgejo.org/forgejo/forgejo-build-publish/build@v3
126146
with:
127147
forgejo: "${{ env.GITHUB_SERVER_URL }}"
128148
owner: "${{ env.GITHUB_REPOSITORY_OWNER }}"
129149
repository: "${{ steps.repository.outputs.value }}"
130150
doer: "${{ secrets.DOER }}"
131-
tag-version: "${{ steps.tag-version.outputs.value }}"
151+
release-version: "${{ steps.release-info.outputs.version }}"
152+
sha: "${{ steps.release-info.outputs.sha }}"
132153
token: "${{ secrets.TOKEN }}"
133154
platforms: linux/amd64,linux/arm64,linux/arm/v6
134155
release-notes: "${{ steps.release-notes.outputs.value }}"
135156
binary-name: forgejo
136157
binary-path: /app/gitea/gitea
137-
verbose: ${{ vars.VERBOSE || 'false' }}
158+
override: "${{ steps.release-info.outputs.override }}"
159+
verbose: ${{ vars.VERBOSE || secrets.VERBOSE || 'false' }}
138160

139161
- name: build rootless container
140162
if: ${{ secrets.TOKEN != '' }}
141-
uses: https://code.forgejo.org/forgejo/forgejo-build-publish/build@v1
163+
uses: https://code.forgejo.org/forgejo/forgejo-build-publish/build@v3
142164
with:
143165
forgejo: "${{ env.GITHUB_SERVER_URL }}"
144166
owner: "${{ env.GITHUB_REPOSITORY_OWNER }}"
145167
repository: "${{ steps.repository.outputs.value }}"
146168
doer: "${{ secrets.DOER }}"
147-
tag-version: "${{ steps.tag-version.outputs.value }}"
169+
release-version: "${{ steps.release-info.outputs.version }}"
170+
sha: "${{ steps.release-info.outputs.sha }}"
148171
token: "${{ secrets.TOKEN }}"
149172
platforms: linux/amd64,linux/arm64,linux/arm/v6
150173
suffix: -rootless
151174
dockerfile: Dockerfile.rootless
152-
verbose: ${{ vars.VERBOSE || 'false' }}
175+
override: "${{ steps.release-info.outputs.override }}"
176+
verbose: ${{ vars.VERBOSE || secrets.VERBOSE || 'false' }}
153177

154178
- name: end-to-end tests
155179
if: ${{ secrets.TOKEN != '' && vars.ROLE == 'forgejo-integration' }}

.forgejo/workflows/mirror.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
name: mirror
22

33
on:
4-
push:
5-
branches:
6-
- 'forgejo'
7-
- 'v*/forgejo'
4+
schedule:
5+
- cron: '@daily'
86

97
jobs:
108
mirror:

0 commit comments

Comments
 (0)