Skip to content

15 files changed

+792
-1
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Emacs
2+
*~
3+
14
# Compiled Object files, Static and Dynamic libs (Shared Objects)
25
*.o
36
*.a

.woodpecker/compliance.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
platform: linux/amd64
2+
3+
when:
4+
event: [ push, pull_request ]
5+
branch:
6+
exclude: [ forgejo-development, main, release/*, soft-fork/*/*, soft-fork/*/*/* ]
7+
8+
variables:
9+
- &golang_image 'golang:1.19'
10+
- &gitea_test_image 'gitea/test_env:linux-amd64'
11+
- &goproxy_override ''
12+
- &goproxy_setup |-
13+
if [ -n "$${GOPROXY_OVERRIDE:-}" ]; then
14+
export GOPROXY="$${GOPROXY_OVERRIDE}";
15+
echo "Using goproxy from goproxy_override \"$${GOPROXY}\"";
16+
elif [ -n "$${GOPROXY_DEFAULT:-}" ]; then
17+
export GOPROXY="$${GOPROXY_DEFAULT}";
18+
echo "Using goproxy from goproxy_default (secret) not displaying";
19+
else
20+
export GOPROXY="https://proxy.golang.org,direct";
21+
echo "No goproxy overrides or defaults given, using \"$${GOPROXY}\"";
22+
fi
23+
24+
workspace:
25+
base: /go
26+
path: src/codeberg/gitea
27+
28+
pipeline:
29+
deps-backend:
30+
image: *golang_image
31+
pull: true
32+
environment:
33+
GOPROXY_OVERRIDE: *goproxy_override
34+
secrets:
35+
- goproxy_default
36+
commands:
37+
- *goproxy_setup
38+
- make deps-backend
39+
40+
security-check:
41+
image: *golang_image
42+
group: checks
43+
pull: true
44+
environment:
45+
GOPROXY_OVERRIDE: *goproxy_override
46+
secrets:
47+
- goproxy_default
48+
commands:
49+
- *goproxy_setup
50+
- make security-check
51+
52+
lint-backend:
53+
image: *gitea_test_image
54+
group: checks
55+
pull: true
56+
environment:
57+
GOPROXY_OVERRIDE: *goproxy_override
58+
TAGS: 'bindata sqlite sqlite_unlock_notify'
59+
GOSUMDB: 'sum.golang.org'
60+
secrets:
61+
- goproxy_default
62+
commands:
63+
- *goproxy_setup
64+
- make lint-backend
65+
66+
checks-backend:
67+
image: *gitea_test_image
68+
pull: true
69+
group: checks
70+
environment:
71+
GOPROXY_OVERRIDE: *goproxy_override
72+
secrets:
73+
- goproxy_default
74+
commands:
75+
- *goproxy_setup
76+
- make --always-make checks-backend

.woodpecker/testing-amd64.yml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
platform: linux/amd64
2+
3+
when:
4+
event: [ push, pull_request ]
5+
branch:
6+
exclude: [ forgejo-development, main, release/*, soft-fork/*/*, soft-fork/*/*/* ]
7+
8+
depends_on:
9+
- compliance
10+
11+
variables:
12+
- &git_image 'docker:git'
13+
- &golang_image 'golang:1.19'
14+
- &gitea_test_image 'gitea/test_env:linux-amd64'
15+
- &mysql_image 'mysql:8'
16+
- &pgsql_image 'postgres:10'
17+
- &goproxy_override ''
18+
- &goproxy_setup |-
19+
if [ -n "$${GOPROXY_OVERRIDE:-}" ]; then
20+
export GOPROXY="$${GOPROXY_OVERRIDE}";
21+
echo "Using goproxy from goproxy_override \"$${GOPROXY}\"";
22+
elif [ -n "$${GOPROXY_DEFAULT:-}" ]; then
23+
export GOPROXY="$${GOPROXY_DEFAULT}";
24+
echo "Using goproxy from goproxy_default (secret) not displaying";
25+
else
26+
export GOPROXY="https://proxy.golang.org,direct";
27+
echo "No goproxy overrides or defaults given, using \"$${GOPROXY}\"";
28+
fi
29+
30+
services:
31+
mysql8:
32+
image: *mysql_image
33+
pull: true
34+
environment:
35+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
36+
MYSQL_DATABASE: testgitea
37+
38+
pgsql:
39+
image: *pgsql_image
40+
pull: true
41+
environment:
42+
POSTGRES_DB: test
43+
POSTGRES_PASSWORD: postgres
44+
45+
workspace:
46+
base: /go
47+
path: src/codeberg/gitea
48+
49+
pipeline:
50+
fetch-tags:
51+
image: *git_image
52+
pull: true
53+
commands:
54+
- git config --add safe.directory '*'
55+
- git fetch --tags --force
56+
57+
deps-backend:
58+
image: *golang_image
59+
pull: true
60+
environment:
61+
GOPROXY_OVERRIDE: *goproxy_override
62+
secrets:
63+
- goproxy_default
64+
commands:
65+
- *goproxy_setup
66+
- make deps-backend
67+
68+
tag-pre-condition:
69+
image: *git_image
70+
pull: true
71+
commands:
72+
- git update-ref refs/heads/tag_test ${CI_COMMIT_SHA}
73+
74+
prepare-test-env:
75+
image: *gitea_test_image
76+
pull: true
77+
commands:
78+
- ./build/test-env-prepare.sh
79+
80+
build:
81+
image: *gitea_test_image
82+
environment:
83+
GOSUMDB: sum.golang.org
84+
TAGS: bindata sqlite sqlite_unlock_notify
85+
GOPROXY_OVERRIDE: *goproxy_override
86+
secrets:
87+
- goproxy_default
88+
commands:
89+
- *goproxy_setup
90+
- su gitea -c './build/test-env-check.sh'
91+
- su gitea -c 'make backend'
92+
93+
unit-test:
94+
image: *gitea_test_image
95+
environment:
96+
TAGS: 'bindata sqlite sqlite_unlock_notify'
97+
RACE_ENABLED: 'true'
98+
GOPROXY_OVERRIDE: *goproxy_override
99+
secrets:
100+
- github_read_token
101+
- goproxy_default
102+
commands:
103+
- *goproxy_setup
104+
- su gitea -c 'make unit-test-coverage test-check'
105+
106+
test-mysql8:
107+
group: integration
108+
image: *gitea_test_image
109+
commands:
110+
- *goproxy_setup
111+
- su gitea -c 'timeout -s ABRT 50m make test-mysql8-migration test-mysql8'
112+
environment:
113+
TAGS: 'bindata'
114+
RACE_ENABLED: 'true'
115+
USE_REPO_TEST_DIR: '1'
116+
GOPROXY_OVERRIDE: *goproxy_override
117+
secrets:
118+
- goproxy_default
119+
120+
test-pgsql:
121+
group: integration
122+
image: *gitea_test_image
123+
commands:
124+
- *goproxy_setup
125+
- su gitea -c 'timeout -s ABRT 50m make test-pgsql-migration test-pgsql'
126+
environment:
127+
TAGS: 'bindata'
128+
RACE_ENABLED: 'true'
129+
USE_REPO_TEST_DIR: '1'
130+
GOPROXY_OVERRIDE: *goproxy_override
131+
secrets:
132+
- goproxy_default
133+
134+
test-sqlite:
135+
group: integration
136+
image: *gitea_test_image
137+
environment:
138+
- USE_REPO_TEST_DIR=1
139+
- GOPROXY=off
140+
- TAGS=bindata gogit sqlite sqlite_unlock_notify
141+
- TEST_TAGS=bindata gogit sqlite sqlite_unlock_notify
142+
commands:
143+
- su gitea -c 'timeout -s ABRT 120m make test-sqlite-migration test-sqlite'

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ $(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ)
733733
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
734734

735735
.PHONY: release
736-
release: frontend generate release-windows release-linux release-darwin release-copy release-compress vendor release-sources release-docs release-check
736+
release: frontend generate release-linux release-copy release-compress vendor release-sources release-check
737737

738738
$(DIST_DIRS):
739739
mkdir -p $(DIST_DIRS)

releases/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM alpine:3.17
2+
3+
RUN echo root > state

releases/Dockerfile-rootless

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
FROM alpine:3.17
2+
3+
RUN echo rootless > state

releases/binaries-pull-push-test.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
5+
test_teardown() {
6+
setup_api
7+
api DELETE repos/$PUSH_USER/forgejo/releases/tags/$TAG || true
8+
api DELETE repos/$PUSH_USER/forgejo/tags/$TAG || true
9+
rm -fr dist/release
10+
setup_tea
11+
$BIN_DIR/tea login delete $RELEASETEAMUSER || true
12+
}
13+
14+
test_setup() {
15+
mkdir -p $RELEASE_DIR
16+
touch $RELEASE_DIR/file-one.txt
17+
touch $RELEASE_DIR/file-two.txt
18+
}
19+
20+
#
21+
# Running the test locally instead of within Woodpecker
22+
#
23+
# 1. Setup: obtain a token at https://codeberg.org/user/settings/applications
24+
# 2. Run: RELEASETEAMUSER=<username> RELEASETEAMTOKEn=<apptoken> binaries-pull-push-test.sh test_run
25+
# 3. Verify: (optional) manual verification at https://codeberg.org/<username>/forgejo/releases
26+
# 4. Cleanup: RELEASETEAMUSER=<username> RELEASETEAMTOKEn=<apptoken> binaries-pull-push-test.sh test_teardown
27+
#
28+
test_run() {
29+
test_teardown
30+
to_push=/tmp/binaries-releases-to-push
31+
pulled=/tmp/binaries-releases-pulled
32+
RELEASE_DIR=$to_push
33+
test_setup
34+
echo "================================ TEST BEGIN"
35+
push
36+
RELEASE_DIR=$pulled
37+
pull
38+
diff -r $to_push $pulled
39+
echo "================================ TEST END"
40+
}
41+
42+
: ${CI_REPO_OWNER:=dachary}
43+
: ${PULL_USER=$CI_REPO_OWNER}
44+
: ${PUSH_USER=$CI_REPO_OWNER}
45+
: ${CI_COMMIT_TAG:=v17.8.20-1}
46+
47+
. $(dirname $0)/binaries-pull-push.sh

releases/binaries-pull-push.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
5+
: ${PULL_USER:=forgejo-integration}
6+
if test "$CI_REPO" = "forgejo/release" ; then
7+
: ${PUSH_USER:=forgejo}
8+
else
9+
: ${PUSH_USER:=forgejo-experimental}
10+
fi
11+
: ${TAG:=${CI_COMMIT_TAG}}
12+
: ${DOMAIN:=codeberg.org}
13+
: ${RELEASE_DIR:=dist/release}
14+
: ${BIN_DIR:=/tmp}
15+
: ${TEA_VERSION:=0.9.0}
16+
17+
18+
setup_tea() {
19+
if ! test -f $BIN_DIR/tea ; then
20+
curl -sL https://dl.gitea.io/tea/$TEA_VERSION/tea-$TEA_VERSION-linux-amd64 > $BIN_DIR/tea
21+
chmod +x $BIN_DIR/tea
22+
fi
23+
}
24+
25+
upload() {
26+
ASSETS=$(ls $RELEASE_DIR/* | sed -e 's/^/-a /')
27+
echo "${CI_COMMIT_TAG##v}" | grep -qi '\-rc' && export RELEASETYPE="--prerelease" && echo "Uploading as Pre-Release"
28+
echo "${CI_COMMIT_TAG##v}" | grep -qi '\-test' && export RELEASETYPE="--draft" && echo "Uploading as Draft"
29+
test ${RELEASETYPE+false} || echo "Uploading as Stable"
30+
anchor=$(echo $CI_COMMIT_TAG | sed -e 's/^v//' -e 's/[^a-zA-Z0-9]/-/g')
31+
$BIN_DIR/tea release create $ASSETS --repo $PUSH_USER/forgejo --note "See https://codeberg.org/forgejo/forgejo/src/branch/forgejo/RELEASE-NOTES.md#${anchor}" --tag $CI_COMMIT_TAG --title $CI_COMMIT_TAG ${RELEASETYPE}
32+
}
33+
34+
push() {
35+
if ! which curl ; then
36+
apk --update --no-cache add curl
37+
fi
38+
setup_tea
39+
GITEA_SERVER_TOKEN=$RELEASETEAMTOKEN $BIN_DIR/tea login add --name $RELEASETEAMUSER --url $DOMAIN
40+
upload
41+
}
42+
43+
setup_api() {
44+
if ! which jq || ! which curl ; then
45+
apk --update --no-cache add jq curl
46+
fi
47+
}
48+
49+
api() {
50+
method=$1
51+
path=$2
52+
53+
curl --fail -X $method -sS -H "Authorization: token $RELEASETEAMTOKEN" https://$DOMAIN/api/v1/$path
54+
}
55+
56+
pull() {
57+
setup_api
58+
(
59+
mkdir -p $RELEASE_DIR
60+
cd $RELEASE_DIR
61+
api GET repos/$PULL_USER/forgejo/releases/tags/$TAG > /tmp/assets.json
62+
jq --raw-output '.assets[] | "\(.name) \(.browser_download_url)"' < /tmp/assets.json | while read name url ; do
63+
wget --quiet -O $name $url
64+
done
65+
)
66+
}
67+
68+
69+
missing() {
70+
echo need pull or push argument got nothing
71+
exit 1
72+
}
73+
74+
${@:-missing}

0 commit comments

Comments
 (0)