Compare commits
300 commits
main
...
forgejo-in
Author | SHA1 | Date | |
---|---|---|---|
|
089d35d1dc | ||
|
857cdc9f29 | ||
|
ffa53456cd | ||
|
2313439ade | ||
|
55391ea452 | ||
|
c877850dee | ||
|
d1e4ada7b4 | ||
|
a2e31f300e | ||
|
ada284d308 | ||
|
e35337144a | ||
|
7d8218b965 | ||
|
4beaf10fbb | ||
|
2f597ab499 | ||
|
222d33af0c | ||
|
7a97f04acc | ||
|
03134ba737 | ||
|
9c085b74c4 | ||
|
fc0775ecdb | ||
|
979c0f604d | ||
|
83c3e832d7 | ||
|
c4c44730ee | ||
|
eb4e3df0f1 | ||
|
8005e37122 | ||
|
fcd27fa94f | ||
|
c9a4c320b1 | ||
|
61904c5565 | ||
|
d67c3f64d6 | ||
|
e86837c658 | ||
|
12d13427a9 | ||
|
8b33ac7b01 | ||
|
6717b76117 | ||
|
a3388d98dc | ||
|
3275d464e5 | ||
|
ff2c6790b3 | ||
|
925c936032 | ||
|
5f9ea45844 | ||
|
ba6c49b79b | ||
|
80b6d688d0 | ||
|
46bfc4e4d7 | ||
|
faaa390f15 | ||
|
46ca949012 | ||
|
5c2eebc521 | ||
|
37572630e8 | ||
|
fca9278771 | ||
|
135bd00a26 | ||
|
beae8629a6 | ||
|
eebf6a1062 | ||
|
adb09f901b | ||
|
65e3fafd02 | ||
|
3d53d7f99e | ||
|
ae389fc5a2 | ||
|
734eb7de64 | ||
|
dacb3b0fac | ||
|
dbe50bffc7 | ||
|
5e0b4c6419 | ||
|
f6f0acae0e | ||
|
d9edb00c72 | ||
|
3bfb74d358 | ||
|
f2214d547f | ||
|
421cdcb03c | ||
|
346b44a198 | ||
|
3de2a36f6c | ||
|
c9e68961b1 | ||
|
186b29a8a0 | ||
|
33d36a0e99 | ||
|
32779c4d6d | ||
|
af5923c7d4 | ||
|
d142c4a60d | ||
|
3450de64aa | ||
|
0a782ec58f | ||
|
ec8c704034 | ||
|
6ce90814b2 | ||
|
b12130646b | ||
|
bc7eb2f245 | ||
|
77e6412295 | ||
|
acb860ef24 | ||
|
33749f5a5e | ||
|
801c760a4e | ||
|
4f84eefa62 | ||
|
0cbcd6763f | ||
|
48f422b903 | ||
|
40906683a3 | ||
|
c4b3c61325 | ||
|
60e90f5bc0 | ||
|
8bf5b2c802 | ||
|
a51b472fef | ||
|
33f3e7eb65 | ||
|
946586b807 | ||
|
aca70a3e54 | ||
|
49e99f95d4 | ||
|
3433d6ced2 | ||
|
6508a9e2ca | ||
|
2374e25593 | ||
|
3875197a1b | ||
|
2db3b373bb | ||
|
f7d1900c5b | ||
|
800cfcc0a8 | ||
|
222313181f | ||
|
c3eb8918b4 | ||
|
631055d190 | ||
|
f48fa02916 | ||
|
54f810c1df | ||
|
294ca18400 | ||
|
09819336a1 | ||
|
94289bc80d | ||
|
26eefbf61b | ||
|
1f2f98fb21 | ||
|
4df9a89f4e | ||
|
427d9ed267 | ||
|
d3bce65195 | ||
|
75503c5396 | ||
|
812385a18c | ||
|
8636471d63 | ||
|
5ad828b7a2 | ||
|
149c6a545c | ||
|
427c46dbf9 | ||
|
996373c707 | ||
|
6224249696 | ||
|
0f4173555f | ||
|
af9305b221 | ||
|
944dd98727 | ||
|
d872865242 | ||
|
497a5d76bb | ||
|
f46d01885f | ||
|
50c5908a91 | ||
|
47a6f7ee78 | ||
|
d5f66e4c0a | ||
|
4e207414d4 | ||
|
2bc5c804ef | ||
|
de08b8c0f5 | ||
|
ad5790b566 | ||
|
631262b3b9 | ||
|
05a341e201 | ||
|
64489247aa | ||
|
63df181d7a | ||
|
87df9095b9 | ||
|
ec9543a6b6 | ||
|
b43cfb6e0c | ||
|
e4fa6d814f | ||
|
148b7ca98c | ||
|
d99352c80e | ||
|
76ac081fb9 | ||
|
6b35ea27c3 | ||
|
cc16df533b | ||
|
c2b7f36bc8 | ||
|
8b3c0a55e7 | ||
|
dca3641cf3 | ||
|
a402d490ba | ||
|
c1ce4361b9 | ||
|
9cfd043b8a | ||
|
233b73d7c8 | ||
|
a1b6e192d9 | ||
|
9b6442bfcf | ||
|
19ce0fe6b1 | ||
|
078107026b | ||
|
b62866f3ae | ||
|
2461666aca | ||
|
4a19e9c90b | ||
|
6f3f3ec0f2 | ||
|
f8dae4b6c1 | ||
|
9e60ae4449 | ||
|
2b8c2826c5 | ||
|
fcb48eff5c | ||
|
7fd268b02f | ||
|
f9e20e7770 | ||
|
abe9f5f52d | ||
|
c6cd39b074 | ||
|
57fdd1cd49 | ||
|
657e367db9 | ||
|
f6da41ec8e | ||
|
56fb137646 | ||
|
872e4632bf | ||
|
90e5b72123 | ||
|
8d48bb7639 | ||
|
9f55d67bd2 | ||
|
888ddb992c | ||
|
d9fc5cee11 | ||
|
2171ed7a5e | ||
|
c5a35b1ad5 | ||
|
e80f12ace9 | ||
|
456dab5002 | ||
|
449890d712 | ||
|
4bff22bc37 | ||
|
8260f4ac6f | ||
|
3bd723d6b8 | ||
|
9ca95cd19a | ||
|
74294d14f0 | ||
|
e9bb6f67e6 | ||
|
416db9031b | ||
|
05341f1ae0 | ||
|
1a3b74f520 | ||
|
174cb37ac9 | ||
|
56110cffcc | ||
|
4a6ed59cb6 | ||
|
922508d1b5 | ||
|
e3a6e1fd8a | ||
|
4f34b12bb2 | ||
|
4a82c559b9 | ||
|
dd768c648e | ||
|
191976a836 | ||
|
c00a5bfc9c | ||
|
0b216e9851 | ||
|
5a5b461453 | ||
|
fbe3c3c59c | ||
|
9a1a91333e | ||
|
6be26d2a69 | ||
|
0afc6ee868 | ||
|
cd377ddbad | ||
|
d8673b8c0b | ||
|
36456ee74f | ||
|
8b6609ac4b | ||
|
f3ec6704ba | ||
|
d69a12b4af | ||
|
be033071a4 | ||
|
4f3e03b917 | ||
|
13f18f9f47 | ||
|
a9a46b7b7d | ||
|
73ef53dce5 | ||
|
e1fd4cbc0f | ||
|
c461ace62b | ||
|
02d263e212 | ||
|
4e517fb4df | ||
|
f4c266f6b2 | ||
|
dd5d55f032 | ||
|
8c9d1ff068 | ||
|
473c9820c9 | ||
|
8d8994f7ea | ||
|
b8c71e7201 | ||
|
96f91063c9 | ||
|
ee1b082c3f | ||
|
81eebc10d8 | ||
|
b563e5cd19 | ||
|
5bb5e037ce | ||
|
8034186267 | ||
|
6bb5e947fb | ||
|
21920b10d9 | ||
|
51f7263dee | ||
|
554d2b48c0 | ||
|
bf689a2478 | ||
|
62f75aa56f | ||
|
2bb546d366 | ||
|
f321bf5d5e | ||
|
8f0f6537c6 | ||
|
9ff495254a | ||
|
dd35a9f1a8 | ||
|
8347d9e040 | ||
|
bf6ece0f52 | ||
|
3ead37ed37 | ||
|
e0c4025af5 | ||
|
f4d0c03302 | ||
|
d7e067b418 | ||
|
b011f038aa | ||
|
be86fe2e44 | ||
|
aa83694fd7 | ||
|
dcab318b4a | ||
|
8bc234e82f | ||
|
1546793d0a | ||
|
bc55c01cc6 | ||
|
4dc1068027 | ||
|
77b08e6e33 | ||
|
67dcb074ea | ||
|
f1fa7c581f | ||
|
cff067a118 | ||
|
78027e672d | ||
|
0f6708163f | ||
|
d885c84bbe | ||
|
9daf947453 | ||
|
fa28ae8fbd | ||
|
985388b5b6 | ||
|
74d11b5eaf | ||
|
d825dac67e | ||
|
5cdebe65db | ||
|
4879daf24a | ||
|
6e3976b17c | ||
|
6236202f09 | ||
|
dcc61603a2 | ||
|
d1d87511f1 | ||
|
f9e93647fb | ||
|
9222919990 | ||
|
d3eb40ac8b | ||
|
465538429e | ||
|
746826e3e6 | ||
|
b648c1cd50 | ||
|
b6591e2f71 | ||
|
3a47977c68 | ||
|
9d4becce06 | ||
|
8aa95dc301 | ||
|
bc1e2aafa9 | ||
|
793c91b254 | ||
|
cb4932192a | ||
|
218494c27f | ||
|
921ed6f481 | ||
|
79cc059d98 | ||
|
42d0557b87 | ||
|
f0570182b8 | ||
|
69747630a9 | ||
|
4768908489 | ||
|
c5cccca38d | ||
|
66b125cffa | ||
|
b63144cb0d |
126 changed files with 3055 additions and 1313 deletions
10
.editorconfig
Normal file
10
.editorconfig
Normal file
|
@ -0,0 +1,10 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
tab_width = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
23
.forgejo/cascading-docs
Executable file
23
.forgejo/cascading-docs
Executable file
|
@ -0,0 +1,23 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
docs=$1
|
||||
docs_pr=$2
|
||||
end_to_end=$3
|
||||
end_to_end_ref=$4
|
||||
|
||||
if ! test -d /srv/contexts ; then
|
||||
echo no contexts in /srv/contexts, do nothing
|
||||
exit 0
|
||||
fi
|
||||
|
||||
cd $docs/docs/user
|
||||
|
||||
if test "$FORCE_VERSION" = "$VERSION" || ! test -f actions-contexts/version.txt || test "$VERSION" != $(cat actions-contexts/version.txt) ; then
|
||||
rm -fr actions-contexts
|
||||
mkdir actions-contexts
|
||||
echo "$VERSION" > actions-contexts/version.txt
|
||||
# populated by actions/run.sh
|
||||
rsync -av /srv/contexts/ actions-contexts/
|
||||
fi
|
30
.forgejo/prepare-end-to-end/action.yml
Normal file
30
.forgejo/prepare-end-to-end/action.yml
Normal file
|
@ -0,0 +1,30 @@
|
|||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: cache S3 binaries
|
||||
id: S3
|
||||
uses: https://code.forgejo.org/actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
/usr/local/bin/minio
|
||||
/usr/local/bin/mc
|
||||
/usr/local/bin/garage
|
||||
key: S3
|
||||
|
||||
- uses: https://code.forgejo.org/actions/setup-forgejo@v2.0.7
|
||||
with:
|
||||
install-only: true
|
||||
- run: forgejo-binary.sh ensure_user forgejo
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: forgejo-dev
|
||||
path: /srv/forgejo-binaries
|
||||
- name: chown/chmod /srv/forgejo-binaries
|
||||
run: |
|
||||
mkdir -p /srv/forgejo-binaries
|
||||
chown -R forgejo /srv/forgejo-binaries
|
||||
chmod -R +x /srv/forgejo-binaries
|
||||
- run: |
|
||||
script=$(pwd)/end-to-end.sh
|
||||
$script run dependencies
|
||||
$script clobber
|
|
@ -1,40 +0,0 @@
|
|||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
|
||||
jobs:
|
||||
actions:
|
||||
runs-on: self-hosted
|
||||
strategy:
|
||||
matrix:
|
||||
info:
|
||||
- binary: https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64
|
||||
version: v1_22
|
||||
tests: ${{ vars.V1_22_TESTS }}
|
||||
- binary: https://codeberg.org/forgejo/forgejo/releases/download/v1.21.3-0/forgejo-1.21.3-0-linux-amd64
|
||||
version: v1_21
|
||||
tests: ${{ vars.V1_21_TESTS }}
|
||||
- binary: https://codeberg.org/forgejo/forgejo/releases/download/v1.20.6-1/forgejo-1.20.6-1-linux-amd64
|
||||
version: v1_20
|
||||
tests: ${{ vars.V1_20_TESTS }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: https://code.forgejo.org/actions/setup-forgejo@v2
|
||||
with:
|
||||
install-only: true
|
||||
|
||||
- if: matrix.info.tests != 'none'
|
||||
shell: bash
|
||||
run: |
|
||||
set -x
|
||||
forgejo-binary.sh ensure_user forgejo
|
||||
test "${{ matrix.info.binary }}"
|
||||
test "${{ matrix.info.version }}"
|
||||
|
||||
export DIR=$(mktemp -d)
|
||||
chown forgejo $DIR /srv
|
||||
|
||||
su -c "actions/run.sh ${{ matrix.info.binary }} ${{ matrix.info.version }} ${{ matrix.info.tests }}" forgejo
|
163
.forgejo/workflows/end-to-end.yml
Normal file
163
.forgejo/workflows/end-to-end.yml
Normal file
|
@ -0,0 +1,163 @@
|
|||
#
|
||||
#
|
||||
# https://code.forgejo.org/forgejo/end-to-end/settings/actions
|
||||
#
|
||||
# secrets.CASCADE_DOCS_ORIGIN_TOKEN
|
||||
# https://code.forgejo.org/forgejo-ci scope write:issue, read:repository, read:user
|
||||
# vars.CASCADE_DOCS_DESTINATION_DOER
|
||||
# forgejo-cascading-pr (https://codeberg.org/forgejo-cascading-pr)
|
||||
# secrets.CASCADE_DOCS_DESTINATION_TOKEN
|
||||
# https://codeberg.org/forgejo-cascading-pr scope write:issue, write:repository, read:user
|
||||
# vars.CASCADE_DOCS_FORCE_VERSION
|
||||
# replace the generated documentation for a given version even if it has already
|
||||
# been generated (e.g. v7.0.0-test)
|
||||
#
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: 'code.forgejo.org/oci/node:20-bookworm'
|
||||
steps:
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
- uses: https://code.forgejo.org/actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.22"
|
||||
- name: lib/build.sh
|
||||
run: |
|
||||
mkdir $d /tmp/forgejo-upload
|
||||
touch /tmp/forgejo-upload/PLACEHOLDER
|
||||
|
||||
if ! test -f forgejo/build-from-sources; then
|
||||
echo forgejo/build-from-sources is not present, do not build any version from source
|
||||
exit 0
|
||||
fi
|
||||
|
||||
set -x
|
||||
#
|
||||
# SQLite needs gcc to be compiled
|
||||
#
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update -qq
|
||||
apt-get -q install -y -qq build-essential
|
||||
|
||||
d=/tmp/forgejo-binaries
|
||||
|
||||
for version in $(cat forgejo/build-from-sources) ; do
|
||||
lib/build.sh $version $d
|
||||
forgejo=$d/forgejo-$version-dev
|
||||
$forgejo --version
|
||||
mv $forgejo /tmp/forgejo-upload/forgejo-$version
|
||||
done
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: forgejo-dev
|
||||
path: /tmp/forgejo-upload
|
||||
|
||||
packages:
|
||||
needs: [build]
|
||||
runs-on: lxc-bookworm
|
||||
steps:
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
- uses: ./.forgejo/prepare-end-to-end
|
||||
- run: su forgejo -c "./end-to-end.sh test_packages"
|
||||
- name: full logs
|
||||
if: always()
|
||||
run: su forgejo -c "./end-to-end.sh show_logs"
|
||||
|
||||
actions:
|
||||
needs: [build]
|
||||
runs-on: lxc-bookworm
|
||||
steps:
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
- uses: ./.forgejo/prepare-end-to-end
|
||||
- run: ./end-to-end.sh prepare_dockerd
|
||||
- run: su forgejo -c "./end-to-end.sh test_actions"
|
||||
- name: full logs
|
||||
if: always()
|
||||
run: su forgejo -c "./end-to-end.sh show_logs"
|
||||
|
||||
federation:
|
||||
needs: [build]
|
||||
runs-on: lxc-bookworm
|
||||
steps:
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
- uses: ./.forgejo/prepare-end-to-end
|
||||
- name: install zstd
|
||||
run: |
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get -q install -y -qq zstd
|
||||
- name: cache GitLab OCI image
|
||||
uses: https://code.forgejo.org/actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
/srv/forgejo-binaries/gitlab
|
||||
key: gitlab
|
||||
- run: |
|
||||
su forgejo -c "./end-to-end.sh test_federation"
|
||||
- name: full logs
|
||||
if: always()
|
||||
run: su forgejo -c "./end-to-end.sh show_logs"
|
||||
|
||||
actions-docs:
|
||||
needs: [build]
|
||||
runs-on: lxc-bookworm
|
||||
if: github.ref == 'refs/heads/main'
|
||||
strategy:
|
||||
matrix:
|
||||
info:
|
||||
- version: "11.0"
|
||||
branch: next
|
||||
forgejo: https://codeberg.org
|
||||
owner: forgejo-experimental
|
||||
- version: "10.0"
|
||||
forgejo: https://codeberg.org
|
||||
owner: forgejo
|
||||
steps:
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
- uses: ./.forgejo/prepare-end-to-end
|
||||
- name: set full-version
|
||||
id: full-version
|
||||
shell: bash
|
||||
run: |
|
||||
set -x
|
||||
full_version=$(./end-to-end.sh full_version ${{ matrix.info.version }} ${{ matrix.info.owner }})
|
||||
echo value="$full_version" >> $GITHUB_OUTPUT
|
||||
- run: ./end-to-end.sh prepare_dockerd
|
||||
- run: su forgejo -c "./end-to-end.sh test_actions ${{ matrix.info.version }}"
|
||||
- name: update documentation
|
||||
uses: https://code.forgejo.org/actions/cascading-pr@v2.1
|
||||
with:
|
||||
origin-url: ${{ env.GITHUB_SERVER_URL }}
|
||||
origin-repo: ${{ github.repository }}
|
||||
origin-token: ${{ secrets.CASCADE_DOCS_ORIGIN_TOKEN }}
|
||||
origin-ref: refs/heads/main
|
||||
destination-url: https://codeberg.org
|
||||
destination-fork-repo: ${{ vars.CASCADE_DOCS_DESTINATION_DOER }}/docs
|
||||
destination-repo: forgejo/docs
|
||||
destination-branch: ${{ matrix.info.branch || format('v{0}', matrix.info.version) }}
|
||||
destination-token: ${{ secrets.CASCADE_DOCS_DESTINATION_TOKEN }}
|
||||
prefix: ${{ env.GITHUB_REPOSITORY }}-${{ matrix.info.version }}
|
||||
update: .forgejo/cascading-docs
|
||||
env:
|
||||
FORCE_VERSION: "${{ vars.CASCADE_DOCS_FORCE_VERSION }}"
|
||||
VERSION: "${{ steps.full-version.outputs.value }}"
|
||||
|
||||
upgrade:
|
||||
name: upgrade and storage
|
||||
needs: [build]
|
||||
runs-on: lxc-bookworm
|
||||
steps:
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
- uses: ./.forgejo/prepare-end-to-end
|
||||
- run: su forgejo -c "./end-to-end.sh test_upgrades"
|
||||
- run: su forgejo -c "./end-to-end.sh test_storage"
|
||||
- name: full logs
|
||||
if: always()
|
||||
run: su forgejo -c "./end-to-end.sh show_logs"
|
|
@ -1,41 +0,0 @@
|
|||
name: upgrade
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
|
||||
jobs:
|
||||
upgrade:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: 'docker.io/node:20-bookworm'
|
||||
steps:
|
||||
- name: cache S3 binaries
|
||||
id: S3
|
||||
uses: https://code.forgejo.org/actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
/usr/local/bin/minio
|
||||
/usr/local/bin/mc
|
||||
/usr/local/bin/garage
|
||||
key: S3
|
||||
|
||||
- name: skip if S3 cache hit
|
||||
if: steps.S3.outputs.cache-hit != 'true'
|
||||
run: echo no hit
|
||||
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
- uses: https://code.forgejo.org/actions/setup-go@v4
|
||||
with:
|
||||
go-version: "1.21"
|
||||
- run: |
|
||||
git config --add safe.directory '*'
|
||||
adduser --quiet --comment forgejo --disabled-password forgejo
|
||||
chown -R forgejo:forgejo .
|
||||
- run: |
|
||||
script=$(pwd)/forgejo/upgrades/test-upgrade.sh
|
||||
$script run dependencies
|
||||
$script clobber
|
||||
su forgejo -c "$script test_upgrades"
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,12 +1,9 @@
|
|||
*~
|
||||
forgejo-api
|
||||
forgejo-header
|
||||
forgejo-ip
|
||||
forgejo-runner-home
|
||||
forgejo-runner-pid
|
||||
forgejo-runner-token
|
||||
forgejo-runner.clientpid
|
||||
forgejo-runner.log
|
||||
forgejo-token
|
||||
.runner
|
||||
#*
|
||||
|
|
93
README.md
93
README.md
|
@ -2,60 +2,93 @@
|
|||
|
||||
A series of tests scenarios and assertions covering
|
||||
[Forgejo](https://codeberg.org/forgejo/forgejo) and the [Forgejo
|
||||
runner](https://code.forgejo.org/forgejo/runner). They partially rely
|
||||
on [Forgejo actions](https://code.forgejo.org/actions) developped
|
||||
specifically for testing such as
|
||||
[setup-forgejo](https://code.forgejo.org/actions/setup-forgejo).
|
||||
runner](https://code.forgejo.org/forgejo/runner).
|
||||
|
||||
They are designed to run using Forgejo releases and development
|
||||
versions compiled from designated repositories.
|
||||
|
||||
## Hacking
|
||||
# Removing legacy tests
|
||||
|
||||
To run and debug workflows from `actions/example-*`, from the root of
|
||||
the source directory, with docker and forgejo-curl.sh installed, mimic
|
||||
what `.forgejo/workflows/actions.yml` does. There may be some manual
|
||||
tweaking (such as creating temporary directories) because the tests
|
||||
run as root in the context of Forgejo Actions and assume they have
|
||||
admin permissions. But they do not need to run as root and must work
|
||||
fine when run as a regular user.
|
||||
End-to-end tests cover the supported range of releases and when one of
|
||||
them is EOL, it must be removed as well as the tests that target it
|
||||
specifically. Otherwise the test suite would grow indefinitely.
|
||||
|
||||
### Prepare the Forgejo instance and the runner
|
||||
When a release is EOL, a branch is cut with a name following the
|
||||
pattern `legacy/vX.Y-vA.B`. For instance when `v8.0` is published and
|
||||
`v1.21` is EOL, the branch `legacy/v8.0-v1.21` is cut.
|
||||
|
||||
# Hacking
|
||||
|
||||
docker and sudo must be installed with insecure registries allowed in
|
||||
/etc/docker/daemon.json for the IP that will be used for forgejo such
|
||||
as:
|
||||
|
||||
```json
|
||||
{
|
||||
"insecure-registries": [ "10.0.0.0/8" ]
|
||||
}
|
||||
```
|
||||
|
||||
Use setup-forgejo from source.
|
||||
|
||||
The [setup-forgejo](https://code.forgejo.org/actions/setup-forgejo)
|
||||
repository is a [Forgejo
|
||||
Action](https://forgejo.org/docs/v7.0/user/actions/) which is meant
|
||||
to be used in workflows. However, it is implemented as shell scripts that
|
||||
can also be used to create Forgejo instances and runners locally. This
|
||||
is convenient for testing and the reason why it needs to be added to the PATH.
|
||||
For instance, it is a dependency of the `end-to-end.sh` script.
|
||||
|
||||
```sh
|
||||
git clone https://code.forgejo.org/actions/setup-forgejo
|
||||
export PATH=$(pwd)/setup-forgejo:$PATH
|
||||
git clone https://code.forgejo.org/forgejo/end-to-end
|
||||
cd end-to-end
|
||||
export DIR=/tmp/end-to-end
|
||||
```
|
||||
|
||||
Run one example
|
||||
## Running from locally built binary
|
||||
|
||||
```sh
|
||||
actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1_22 cron # runs actions/example-cron
|
||||
make TAGS='bindata sqlite sqlite_unlock_notify' generate forgejo
|
||||
cp -a forgejo /srv/forgejo-binaries/forgejo-10.0
|
||||
```
|
||||
|
||||
Cleanup
|
||||
It will be used whenever the version `10.0` is specified in a test.
|
||||
|
||||
## Running actions locally
|
||||
|
||||
To run and debug workflows from `actions/example-*`, from the root of
|
||||
the source directory, with docker and forgejo-curl.sh installed, mimic
|
||||
what `.forgejo/workflows/end-to-end.yml` does. There may be some manual
|
||||
tweaking (such as creating temporary directories) because the tests
|
||||
run as root in the context of Forgejo Actions and assume they have
|
||||
admin permissions. But they do not need to run as root and must work
|
||||
fine when run as a regular user.
|
||||
|
||||
```sh
|
||||
actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1_22 none
|
||||
./end-to-end.sh run dependencies
|
||||
./end-to-end.sh actions_setup 10.0
|
||||
firefox 0.0.0.0:3000 # user root / admin1234
|
||||
./end-to-end.sh actions_verify_example echo
|
||||
./end-to-end.sh actions_teardown
|
||||
```
|
||||
|
||||
Run all examples for v1_22
|
||||
Note that `with-docker-tcp` requires the docker daemon listens to
|
||||
tcp://127.0.0.1:2375. See `actions/actions.sh` for how to do that.
|
||||
|
||||
## Running other tests locally
|
||||
|
||||
To run and debug tests, from the root of the source directory.
|
||||
|
||||
Run one test. When the test fails the instance can be inspected at http://0.0.0.0:3000
|
||||
|
||||
```sh
|
||||
actions/run.sh https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64 v1_22
|
||||
./end-to-end.sh test_packages_alpine
|
||||
./end-to-end.sh test_storage_stable_s3 minio
|
||||
```
|
||||
|
||||
### Remote testing
|
||||
Cleanup. It will teardown the Forgejo instance.
|
||||
|
||||
To reduce the runtime the following variables can be set to control
|
||||
the number of cases run by the
|
||||
[actions](.forgejo/workflows/actions.yml) tests. If set to
|
||||
**none** they are not run at all for that version of Forgejo. If
|
||||
it does not exist, all tests are run.
|
||||
|
||||
* `V1_22_TESTS`
|
||||
* `V1_21_TESTS`
|
||||
* `V1_20_TESTS`
|
||||
```sh
|
||||
./end-to-end.sh stop
|
||||
```
|
||||
|
|
172
actions/actions.sh
Executable file
172
actions/actions.sh
Executable file
|
@ -0,0 +1,172 @@
|
|||
# Copyright 2024 The Forgejo Authors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
ACTIONS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
function actions_export_variables() {
|
||||
export HOST_PORT
|
||||
export url=http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT}
|
||||
export token=$(cat $DOT_FORGEJO_CURL/token)
|
||||
}
|
||||
|
||||
function actions_verify_feature() {
|
||||
local feature=$1
|
||||
|
||||
actions_export_variables
|
||||
|
||||
export FEATURE_DIR=$ACTIONS_DIR/feature-$feature
|
||||
|
||||
echo "============================ RUN feature-$feature ==================="
|
||||
bash -ex $FEATURE_DIR/run.sh || return 1
|
||||
}
|
||||
|
||||
function actions_verify_example() {
|
||||
local example=$1
|
||||
|
||||
actions_export_variables
|
||||
actions_cleanup_example_volume
|
||||
|
||||
export example
|
||||
export EXAMPLE_DIR=$ACTIONS_DIR/example-$example
|
||||
|
||||
if test -f $EXAMPLE_DIR/setup.sh; then
|
||||
echo "============================ SETUP example-$example ==================="
|
||||
bash -ex $EXAMPLE_DIR/setup.sh || return 1
|
||||
fi
|
||||
|
||||
if test -f $EXAMPLE_DIR/run.sh; then
|
||||
echo "============================ RUN example-$example ==================="
|
||||
bash -ex $EXAMPLE_DIR/run.sh || return 1
|
||||
else
|
||||
forgejo-test-helper.sh run_workflow actions/example-$example $url root example-$example $example $token || return 1
|
||||
fi
|
||||
|
||||
if test -f $EXAMPLE_DIR/teardown.sh; then
|
||||
echo "============================ TEARDOWN example-$example ==================="
|
||||
bash -ex $EXAMPLE_DIR/teardown.sh || return 1
|
||||
fi
|
||||
|
||||
actions_save_contexts $example
|
||||
}
|
||||
|
||||
function actions_save_contexts() {
|
||||
local example="$1"
|
||||
|
||||
if test -d /srv/example/$example/contexts; then
|
||||
mkdir -p /srv/contexts
|
||||
rsync -av /srv/example/$example/contexts/ /srv/contexts/$example/
|
||||
fi
|
||||
}
|
||||
|
||||
function actions_cleanup_example_volume() {
|
||||
if test $(id -u) != 0; then
|
||||
$SUDO chown $(id -u) /srv
|
||||
fi
|
||||
|
||||
if ! test -d /srv/example; then
|
||||
mkdir -p /srv/example
|
||||
return
|
||||
fi
|
||||
|
||||
$SUDO rm -fr /srv/example/*
|
||||
}
|
||||
|
||||
function actions_setup() {
|
||||
local version=$1
|
||||
actions_teardown
|
||||
|
||||
reset_forgejo $ACTIONS_DIR/default-app.ini
|
||||
start_forgejo $version
|
||||
|
||||
export FORGEJO_RUNNER_LOGS=$DIR/forgejo-runner.log
|
||||
|
||||
actions_cleanup_example_volume
|
||||
export FORGEJO_RUNNER_CONFIG=$ACTIONS_DIR/runner-config.yaml
|
||||
forgejo-runner.sh setup '' '' http://${HOST_PORT}
|
||||
}
|
||||
|
||||
function actions_teardown() {
|
||||
forgejo-curl.sh logout
|
||||
forgejo-runner.sh teardown
|
||||
stop_forgejo
|
||||
}
|
||||
|
||||
function actions_runner_version() {
|
||||
local runner_version=$($DIR/forgejo-runner --version | sed -n -e 's/forgejo-runner version v//p')
|
||||
if test -z "$runner_version"; then
|
||||
$DIR/forgejo-runner --version
|
||||
echo failed to parse version
|
||||
false
|
||||
fi
|
||||
echo $runner_version
|
||||
}
|
||||
|
||||
function prepare_dockerd() {
|
||||
mkdir -p /etc/systemd/system/docker.service.d
|
||||
cat >/etc/systemd/system/docker.service.d/override.conf <<'EOF'
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=/usr/sbin/dockerd -H unix:///var/run/docker.sock -H tcp://127.0.0.1:2375 --containerd=/run/containerd/containerd.sock $DOCKER_OPTS
|
||||
EOF
|
||||
systemctl daemon-reload
|
||||
if ! systemctl restart docker.service; then
|
||||
journalctl --no-pager --unit docker.service
|
||||
return 1
|
||||
fi
|
||||
netstat -lntp | grep 127.0.0.1:2375
|
||||
}
|
||||
|
||||
function test_actions() {
|
||||
local versions="${1:-$RELEASE_NUMBERS}"
|
||||
|
||||
for version in $versions; do
|
||||
|
||||
actions_setup $version
|
||||
local runner_version=$(actions_runner_version)
|
||||
|
||||
log_info "Testing actions with Forgejo $version & Forgejo runner $runner_version"
|
||||
|
||||
run actions_verify_example with-docker-tcp
|
||||
if dpkg --compare-versions $runner_version gt 5.0.2; then
|
||||
for example in with-docker-host with-docker-socket without-docker-socket; do
|
||||
run actions_verify_example $example
|
||||
done
|
||||
fi
|
||||
|
||||
if dpkg --compare-versions $runner_version gt 6.0.1; then
|
||||
run actions_verify_example force-rebuild
|
||||
fi
|
||||
|
||||
if dpkg --compare-versions $version ge 7.0 && dpkg --compare-versions $runner_version gt 3.3.0; then
|
||||
for example in artifacts-v4; do
|
||||
run actions_verify_example $example
|
||||
done
|
||||
fi
|
||||
|
||||
for example in echo config-options cache checkout service container expression local-action docker-action if if-fail push tag push-cancel artifacts pull-request context; do
|
||||
run actions_verify_example $example
|
||||
done
|
||||
|
||||
if dpkg --compare-versions $version lt 7.1; then
|
||||
for example in cron; do
|
||||
run actions_verify_example $example
|
||||
done
|
||||
fi
|
||||
|
||||
if dpkg --compare-versions $version ge 7.1; then
|
||||
for example in automerge post-7-0-schedule; do
|
||||
run actions_verify_example $example
|
||||
done
|
||||
fi
|
||||
|
||||
if dpkg --compare-versions $version ge 8.0; then
|
||||
for example in workflow-dispatch; do
|
||||
run actions_verify_example $example
|
||||
done
|
||||
fi
|
||||
|
||||
if dpkg --compare-versions $version ge 9.0; then
|
||||
run actions_verify_example schedule-noncancel
|
||||
fi
|
||||
done
|
||||
}
|
|
@ -1,18 +1,23 @@
|
|||
RUN_MODE = prod
|
||||
WORK_PATH = ${WORK_PATH}
|
||||
RUN_MODE = dev
|
||||
WORK_PATH = forgejo-work-path
|
||||
|
||||
[server]
|
||||
APP_DATA_PATH = ${WORK_PATH}/data
|
||||
DOMAIN = ${IP}
|
||||
HTTP_PORT = 3000
|
||||
SSH_LISTEN_PORT = 2222
|
||||
LFS_START_SERVER = true
|
||||
|
||||
[queue]
|
||||
TYPE = immediate
|
||||
|
||||
[database]
|
||||
DB_TYPE = sqlite3
|
||||
PATH = ${WORK_PATH}/forgejo.db
|
||||
|
||||
[log]
|
||||
MODE = file
|
||||
LEVEL = debug
|
||||
LEVEL = trace
|
||||
ROUTER = file
|
||||
|
||||
[log.file]
|
||||
|
@ -24,21 +29,7 @@ INSTALL_LOCK = true
|
|||
[repository]
|
||||
ENABLE_PUSH_CREATE_USER = true
|
||||
DEFAULT_PUSH_CREATE_PRIVATE = false
|
||||
DEFAULT_REPO_UNITS = repo.code,repo.releases,repo.issues,repo.pulls,repo.wiki,repo.projects,repo.packages,repo.actions
|
||||
|
||||
[attachment]
|
||||
PATH = relative-attachments
|
||||
|
||||
[lfs]
|
||||
PATH = relative-lfs
|
||||
|
||||
[avatar]
|
||||
PATH = relative-avatars
|
||||
|
||||
[repo-avatar]
|
||||
PATH = relative-repo-avatars
|
||||
|
||||
[repo-archive]
|
||||
PATH = relative-repo-archive
|
||||
|
||||
[packages]
|
||||
PATH = relative-packages
|
||||
[actions]
|
||||
ENABLED = true
|
47
actions/example-artifacts-v4/.forgejo/workflows/test.yml
Normal file
47
actions/example-artifacts-v4/.forgejo/workflows/test.yml
Normal file
|
@ -0,0 +1,47 @@
|
|||
on: [push]
|
||||
jobs:
|
||||
upload-many:
|
||||
runs-on: docker
|
||||
steps:
|
||||
- run: mkdir -p artifacts
|
||||
|
||||
- run: touch artifacts/ONE artifacts/TWO
|
||||
|
||||
- uses: https://code.forgejo.org/forgejo/upload-artifact@v4
|
||||
with:
|
||||
name: many-artifacts
|
||||
path: artifacts/
|
||||
|
||||
download-many:
|
||||
needs: [upload-many]
|
||||
runs-on: docker
|
||||
steps:
|
||||
- uses: https://code.forgejo.org/forgejo/download-artifact@v4
|
||||
|
||||
- run: |
|
||||
test -f many-artifacts/ONE
|
||||
test -f many-artifacts/TWO
|
||||
|
||||
upload-one:
|
||||
runs-on: docker
|
||||
steps:
|
||||
- run: mkdir -p path/to/artifact
|
||||
|
||||
- run: echo hello > path/to/artifact/world.txt
|
||||
|
||||
- uses: https://code.forgejo.org/forgejo/upload-artifact@v4
|
||||
with:
|
||||
name: my-artifact
|
||||
path: path/to/artifact/world.txt
|
||||
|
||||
download-one:
|
||||
needs: [upload-one]
|
||||
runs-on: docker
|
||||
steps:
|
||||
- run: "! test -f world.txt"
|
||||
|
||||
- uses: https://code.forgejo.org/forgejo/download-artifact@v4
|
||||
with:
|
||||
name: my-artifact
|
||||
|
||||
- run: "test -f world.txt"
|
13
actions/example-automerge/.forgejo/workflows/test.yml
Normal file
13
actions/example-automerge/.forgejo/workflows/test.yml
Normal file
|
@ -0,0 +1,13 @@
|
|||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: code.forgejo.org/oci/node:20-bookworm
|
||||
options: "--volume /srv/example:/srv/example"
|
||||
|
||||
steps:
|
||||
- run: |
|
||||
${{ vars.SCRIPT }}
|
108
actions/example-automerge/run.sh
Executable file
108
actions/example-automerge/run.sh
Executable file
|
@ -0,0 +1,108 @@
|
|||
TMPDIR=$(mktemp -d)
|
||||
|
||||
trap "rm -fr $TMPDIR" EXIT
|
||||
|
||||
source $EXAMPLE_DIR/../../lib/lib.sh
|
||||
|
||||
api=$url/api/v1
|
||||
repo=root/example-automerge
|
||||
export d=/srv/example/automerge
|
||||
|
||||
function reset_automerge_pr() {
|
||||
#
|
||||
# repository with a pull_request event workflow that always succeeds
|
||||
#
|
||||
mkdir -p $d
|
||||
|
||||
forgejo-curl.sh api_json -X DELETE $api/repos/$repo >&/dev/null || true
|
||||
forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token
|
||||
|
||||
forgejo-curl.sh api_json -X DELETE $api/repos/$repo/actions/variables/SCRIPT >&/dev/null || true
|
||||
forgejo-curl.sh api_json -X POST --data-raw '{"value":"true"}' $api/repos/$repo/actions/variables/SCRIPT
|
||||
|
||||
(
|
||||
cd $d
|
||||
rm -fr example-automerge
|
||||
git clone $url/$repo
|
||||
cd example-automerge
|
||||
git checkout -b other
|
||||
git config user.email root@example.com
|
||||
git config user.name username
|
||||
touch file-unique-to-the-pr-branch
|
||||
echo other >>README
|
||||
git add .
|
||||
git commit -m 'other change'
|
||||
git push --force -u origin other
|
||||
)
|
||||
|
||||
#
|
||||
# make sure the runner won't race with the sequence that follows
|
||||
#
|
||||
forgejo-runner.sh teardown
|
||||
#
|
||||
# create a PR and schedule it for automerge when the workflow succeeds
|
||||
#
|
||||
api_pr_delete_all $api $repo
|
||||
forgejo-curl.sh api_json --data-raw '{"title":"PR title","base":"main","head":"other"}' $api/repos/$repo/pulls >$TMPDIR/pr.json
|
||||
local pr=$(jq -r .number <$TMPDIR/pr.json)
|
||||
forgejo-curl.sh api_json --data-raw '{"Do":"merge","merge_when_checks_succeed":true}' $api/repos/$repo/pulls/$pr/merge
|
||||
if api_pr_is_merged $api $repo $pr; then
|
||||
echo pull request already merged although it should not be
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function verify_automerge_on_status_success() {
|
||||
reset_automerge_pr
|
||||
local pr=$(jq -r .number <$TMPDIR/pr.json)
|
||||
#
|
||||
# run the workflow
|
||||
#
|
||||
forgejo-runner.sh run
|
||||
local sha=$(api_branch_tip $api $repo other)
|
||||
api_pr_wait_success $api $repo $sha
|
||||
#
|
||||
# verify the PR was automerged
|
||||
#
|
||||
if ! retry api_pr_is_merged $api $repo $pr; then
|
||||
echo pull request is not automerged as expected
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function verify_automerge_on_reviewer_approval() {
|
||||
reset_automerge_pr
|
||||
local pr=$(jq -r .number <$TMPDIR/pr.json)
|
||||
#
|
||||
# require at least one review for a PR to be merged
|
||||
#
|
||||
api_branch_protect $api $repo main
|
||||
#
|
||||
# run the workflow
|
||||
#
|
||||
forgejo-runner.sh run
|
||||
local sha=$(api_branch_tip $api $repo other)
|
||||
api_pr_wait_success $api $repo $sha
|
||||
#
|
||||
# approve the PR
|
||||
#
|
||||
local username=user1
|
||||
api_user_create $api $username $username@example.com
|
||||
api_user_make_admin $api $username
|
||||
user_login $username
|
||||
DOT=$API_TMPDIR/$username api_pr_approve $api $repo $pr
|
||||
#
|
||||
# verify the PR was automerged
|
||||
#
|
||||
if ! retry api_pr_is_merged $api $repo $pr; then
|
||||
echo pull request is not automerged as expected
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function main() {
|
||||
verify_automerge_on_status_success
|
||||
verify_automerge_on_reviewer_approval
|
||||
}
|
||||
|
||||
main
|
1
actions/example-automerge/setup.sh
Executable file
1
actions/example-automerge/setup.sh
Executable file
|
@ -0,0 +1 @@
|
|||
mkdir -p /srv/example/automerge
|
51
actions/example-cache/.forgejo/workflows/test.yml
Normal file
51
actions/example-cache/.forgejo/workflows/test.yml
Normal file
|
@ -0,0 +1,51 @@
|
|||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: code.forgejo.org/oci/node:20-bookworm
|
||||
steps:
|
||||
- name: cache restore
|
||||
id: cachestep1
|
||||
uses: https://code.forgejo.org/actions/cache/restore@v4
|
||||
with:
|
||||
path: |
|
||||
/usr/local/bin/something
|
||||
key: cachekey
|
||||
|
||||
- name: cache hit
|
||||
run: |
|
||||
set -x
|
||||
test "${{ steps.cachestep1.outputs.cache-hit }}" != true
|
||||
|
||||
- name: create something
|
||||
run: echo SOMETHING > /usr/local/bin/something
|
||||
|
||||
- name: cache save
|
||||
uses: https://code.forgejo.org/actions/cache/save@v4
|
||||
with:
|
||||
path: |
|
||||
/usr/local/bin/something
|
||||
key: ${{ steps.cachestep1.outputs.cache-primary-key }}
|
||||
|
||||
- name: remove something
|
||||
run: rm /usr/local/bin/something
|
||||
|
||||
- name: cache restore
|
||||
id: cachestep2
|
||||
uses: https://code.forgejo.org/actions/cache/restore@v4
|
||||
with:
|
||||
path: |
|
||||
/usr/local/bin/something
|
||||
key: cachekey
|
||||
|
||||
- name: verify something
|
||||
run: |
|
||||
set -x
|
||||
test SOMETHING = $(cat /usr/local/bin/something)
|
||||
|
||||
- name: cache hit
|
||||
run: |
|
||||
set -x
|
||||
test "${{ steps.cachestep2.outputs.cache-hit }}" = true
|
30
actions/example-cache/runner-config.yaml
Normal file
30
actions/example-cache/runner-config.yaml
Normal file
|
@ -0,0 +1,30 @@
|
|||
|
||||
log:
|
||||
level: debug
|
||||
|
||||
runner:
|
||||
file: .runner
|
||||
capacity: 1
|
||||
env_file: .env
|
||||
timeout: 3h
|
||||
insecure: false
|
||||
fetch_timeout: 5s
|
||||
fetch_interval: 2s
|
||||
labels: ["docker:docker://code.forgejo.org/oci/node:20-bookworm"]
|
||||
|
||||
cache:
|
||||
enabled: true
|
||||
dir: "/srv/example/cache"
|
||||
host: ""
|
||||
port: 0
|
||||
|
||||
container:
|
||||
network: "bridge"
|
||||
privileged: false
|
||||
options:
|
||||
workdir_parent:
|
||||
valid_volumes: ["/srv/example"]
|
||||
docker_host: ""
|
||||
|
||||
host:
|
||||
workdir_parent:
|
1
actions/example-cache/setup.sh
Executable file
1
actions/example-cache/setup.sh
Executable file
|
@ -0,0 +1 @@
|
|||
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload
|
16
actions/example-config-options/.forgejo/workflows/test.yml
Normal file
16
actions/example-config-options/.forgejo/workflows/test.yml
Normal file
|
@ -0,0 +1,16 @@
|
|||
on: [push]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: docker
|
||||
container:
|
||||
options: "--hostname customname"
|
||||
steps:
|
||||
- run: |
|
||||
test -f /srv/example-config-options-volume-valid
|
||||
- run: |
|
||||
! test -f /srv/example-config-options-volume-invalid
|
||||
- run: |
|
||||
test "$FROB" = "NITZ"
|
||||
- run: |
|
||||
test "$(cat /etc/hostname)" = customname
|
31
actions/example-config-options/runner-config.yaml
Normal file
31
actions/example-config-options/runner-config.yaml
Normal file
|
@ -0,0 +1,31 @@
|
|||
|
||||
log:
|
||||
level: debug
|
||||
job_level: debug
|
||||
|
||||
runner:
|
||||
file: .runner
|
||||
capacity: 1
|
||||
env_file: .env
|
||||
timeout: 3h
|
||||
insecure: false
|
||||
fetch_timeout: 5s
|
||||
fetch_interval: 2s
|
||||
labels: ["docker:docker://code.forgejo.org/oci/node:20-bookworm"]
|
||||
|
||||
cache:
|
||||
enabled: false
|
||||
dir: ""
|
||||
host: ""
|
||||
port: 0
|
||||
|
||||
container:
|
||||
network: ""
|
||||
privileged: false
|
||||
options: "--volume /srv/example-config-options-volume-valid:/srv/example-config-options-volume-valid --volume /srv/example-config-options-volume-invalid:/srv/example-config-options-volume-invalid --env FROB=NITZ"
|
||||
workdir_parent:
|
||||
valid_volumes: ["/srv/example-config-options-volume-valid"]
|
||||
docker_host: ""
|
||||
|
||||
host:
|
||||
workdir_parent:
|
3
actions/example-config-options/setup.sh
Executable file
3
actions/example-config-options/setup.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
>/srv/example-config-options-volume-valid
|
||||
>/srv/example-config-options-volume-invalid
|
||||
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload
|
|
@ -3,6 +3,6 @@ jobs:
|
|||
test:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: alpine:3.18
|
||||
image: code.forgejo.org/oci/alpine:3.21
|
||||
steps:
|
||||
- run: grep Alpine /etc/os-release
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
ONE
|
206
actions/example-context/.forgejo/workflows/test.yml
Normal file
206
actions/example-context/.forgejo/workflows/test.yml
Normal file
|
@ -0,0 +1,206 @@
|
|||
on: [push]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: code.forgejo.org/oci/node:20-bookworm
|
||||
volumes:
|
||||
- /srv/example:/srv/example
|
||||
steps:
|
||||
|
||||
- name: env.CI
|
||||
run: |
|
||||
set -x
|
||||
test "$CI" = true
|
||||
test "$CI" = "${{ env.CI }}"
|
||||
|
||||
- name: GITHUB_ACTION
|
||||
run: |
|
||||
set -x
|
||||
echo "$GITHUB_ACTION" | grep -E '^[0-9]+$'
|
||||
test "$GITHUB_ACTION" = "${{ env.GITHUB_ACTION }}"
|
||||
test "$GITHUB_ACTION" = "${{ github.ACTION }}"
|
||||
|
||||
# See also actions/example-local-action/.forgejo/local-action/action.yml
|
||||
- name: GITHUB_ACTION_PATH
|
||||
run: |
|
||||
set -x
|
||||
test -z "$GITHUB_ACTION_PATH"
|
||||
test "$GITHUB_ACTION_PATH" = "${{ env.GITHUB_ACTION_PATH }}"
|
||||
test "$GITHUB_ACTION_PATH" = "${{ github.ACTION_PATH }}"
|
||||
|
||||
- name: when running an action
|
||||
if: ${{ env.GITHUB_ACTIONS }}
|
||||
uses: SELF@main
|
||||
with:
|
||||
input-one: "otherone"
|
||||
|
||||
- name: GITHUB_ACTION_REPOSITORY
|
||||
run: test -f /srv/example/example-context/GITHUB_ACTION_REPOSITORY
|
||||
|
||||
- name: GITHUB_ACTION_PATH
|
||||
run: test -f /srv/example/example-context/GITHUB_ACTION_PATH
|
||||
|
||||
- name: GITHUB_ACTIONS
|
||||
run: |
|
||||
set -x
|
||||
test "$GITHUB_ACTIONS" = true
|
||||
test "$GITHUB_ACTIONS" = "${{ env.GITHUB_ACTIONS }}"
|
||||
|
||||
- name: GITHUB_ACTOR
|
||||
run: |
|
||||
set -x
|
||||
test "$GITHUB_ACTOR"
|
||||
test "$GITHUB_ACTOR" = "${{ env.GITHUB_ACTOR }}"
|
||||
test "$GITHUB_ACTOR" = "${{ github.ACTOR }}"
|
||||
|
||||
- name: GITHUB_API_URL
|
||||
shell: bash
|
||||
run: |
|
||||
set -x
|
||||
[[ "$GITHUB_API_URL" =~ /api/v1$ ]]
|
||||
test "$GITHUB_API_URL" = "${{ env.GITHUB_API_URL }}"
|
||||
test "$GITHUB_API_URL" = "${{ github.API_URL }}"
|
||||
|
||||
# See also actions/example-pull-request/.forgejo/workflows/test.yml
|
||||
- name: GITHUB_BASE_REF
|
||||
run: |
|
||||
set -x
|
||||
test -z "$GITHUB_BASE_REF"
|
||||
test "$GITHUB_BASE_REF" = "${{ env.GITHUB_BASE_REF }}"
|
||||
test "$GITHUB_BASE_REF" = "${{ github.BASE_REF }}"
|
||||
|
||||
# See also actions/example-pull-request/.forgejo/workflows/test.yml
|
||||
- name: GITHUB_HEAD_REF
|
||||
run: |
|
||||
set -x
|
||||
test -z "$GITHUB_HEAD_REF"
|
||||
test "$GITHUB_HEAD_REF" = "${{ env.GITHUB_HEAD_REF }}"
|
||||
test "$GITHUB_HEAD_REF" = "${{ github.HEAD_REF }}"
|
||||
|
||||
- name: GITHUB_ENV
|
||||
run: |
|
||||
set -x
|
||||
test -f "$GITHUB_ENV"
|
||||
test "$GITHUB_ENV" = "${{ env.GITHUB_ENV }}"
|
||||
|
||||
- name: GITHUB_EVENT_NAME
|
||||
run: |
|
||||
set -x
|
||||
test "$GITHUB_EVENT_NAME" = push
|
||||
test "$GITHUB_EVENT_NAME" = "${{ env.GITHUB_EVENT_NAME }}"
|
||||
test "$GITHUB_EVENT_NAME" = "${{ github.EVENT_NAME }}"
|
||||
|
||||
- name: GITHUB_JOB
|
||||
run: |
|
||||
set -x
|
||||
test "$GITHUB_JOB" = test
|
||||
test "$GITHUB_JOB" = "${{ env.GITHUB_JOB }}"
|
||||
test "$GITHUB_JOB" = "${{ github.JOB }}"
|
||||
|
||||
- name: GITHUB_OUTPUT
|
||||
run: |
|
||||
set -x
|
||||
test -f "$GITHUB_OUTPUT"
|
||||
test "$GITHUB_OUTPUT" = "${{ env.GITHUB_OUTPUT }}"
|
||||
|
||||
- name: GITHUB_PATH
|
||||
run: |
|
||||
set -x
|
||||
test -f "$GITHUB_PATH"
|
||||
test "$GITHUB_PATH" = "${{ env.GITHUB_PATH }}"
|
||||
|
||||
- name: GITHUB_REF
|
||||
shell: bash
|
||||
run: |
|
||||
set -x
|
||||
[[ "$GITHUB_REF" =~ ^refs/ ]]
|
||||
test "$GITHUB_REF" = "${{ env.GITHUB_REF }}"
|
||||
test "$GITHUB_REF" = "${{ github.REF }}"
|
||||
|
||||
- name: GITHUB_REF_NAME
|
||||
shell: bash
|
||||
run: |
|
||||
set -x
|
||||
! [[ "$GITHUB_REF_NAME" =~ ^refs/ ]]
|
||||
test "$GITHUB_REF_NAME" = "${{ env.GITHUB_REF_NAME }}"
|
||||
test "$GITHUB_REF_NAME" = "${{ github.REF_NAME }}"
|
||||
|
||||
- name: GITHUB_REPOSITORY
|
||||
run: |
|
||||
set -x
|
||||
test "$GITHUB_REPOSITORY" = root/example-context
|
||||
test "$GITHUB_REPOSITORY" = "${{ env.GITHUB_REPOSITORY }}"
|
||||
test "$GITHUB_REPOSITORY" = "${{ github.REPOSITORY }}"
|
||||
|
||||
- name: GITHUB_REPOSITORY_OWNER
|
||||
run: |
|
||||
set -x
|
||||
test "$GITHUB_REPOSITORY_OWNER" = root
|
||||
test "$GITHUB_REPOSITORY_OWNER" = "${{ env.GITHUB_REPOSITORY_OWNER }}"
|
||||
test "$GITHUB_REPOSITORY_OWNER" = "${{ github.REPOSITORY_OWNER }}"
|
||||
|
||||
- name: GITHUB_RUN_NUMBER
|
||||
run: |
|
||||
set -x
|
||||
echo "$GITHUB_RUN_NUMBER" | grep -E '^[0-9]+$'
|
||||
test "$GITHUB_RUN_NUMBER" = "${{ env.GITHUB_RUN_NUMBER }}"
|
||||
test "$GITHUB_RUN_NUMBER" = "${{ github.RUN_NUMBER }}"
|
||||
|
||||
- name: GITHUB_SERVER_URL
|
||||
shell: bash
|
||||
run: |
|
||||
set -x
|
||||
[[ "$GITHUB_SERVER_URL" =~ ^http ]]
|
||||
test "$GITHUB_SERVER_URL" = "${{ env.GITHUB_SERVER_URL }}"
|
||||
test "$GITHUB_SERVER_URL" = "${{ github.SERVER_URL }}"
|
||||
|
||||
- name: GITHUB_SHA
|
||||
run: |
|
||||
set -x
|
||||
test "$GITHUB_SHA"
|
||||
test "$GITHUB_SHA" = "${{ env.GITHUB_SHA }}"
|
||||
test "$GITHUB_SHA" = "${{ github.SHA }}"
|
||||
|
||||
- name: GITHUB_STEP_SUMMARY
|
||||
run: |
|
||||
set -x
|
||||
test -f "$GITHUB_STEP_SUMMARY"
|
||||
test "$GITHUB_STEP_SUMMARY" = "${{ env.GITHUB_STEP_SUMMARY }}"
|
||||
|
||||
# See also actions/example-pull-request/.forgejo/workflows/test.yml
|
||||
- name: GITHUB_TOKEN
|
||||
run: |
|
||||
set -x
|
||||
test "$GITHUB_TOKEN"
|
||||
test "$GITHUB_TOKEN" = "${{ env.GITHUB_TOKEN }}"
|
||||
test "$GITHUB_TOKEN" = "${{ github.TOKEN }}"
|
||||
|
||||
- name: GITHUB_WORKSPACE
|
||||
run: |
|
||||
set -x
|
||||
test -d "$GITHUB_WORKSPACE"
|
||||
test "$GITHUB_WORKSPACE" = "${{ env.GITHUB_WORKSPACE }}"
|
||||
test "$GITHUB_WORKSPACE" = "${{ github.WORKSPACE }}"
|
||||
|
||||
- name: RUNNER_ARCH
|
||||
run: |
|
||||
set -x
|
||||
test "$RUNNER_ARCH" = X64
|
||||
|
||||
- name: RUNNER_OS
|
||||
run: |
|
||||
set -x
|
||||
test "$RUNNER_OS" = Linux
|
||||
|
||||
# runner 3.3.0 $RUNNER_TOOL_CACHE is not an existing directory
|
||||
# - name: RUNNER_TOOL_CACHE
|
||||
# run: |
|
||||
# set -x
|
||||
# test -d "$RUNNER_TOOL_CACHE"
|
||||
|
||||
- name: RUNNER_TEMP
|
||||
run: |
|
||||
set -x
|
||||
test -d "$RUNNER_TEMP"
|
23
actions/example-context/action-for-context/action.yml
Normal file
23
actions/example-context/action-for-context/action.yml
Normal file
|
@ -0,0 +1,23 @@
|
|||
inputs:
|
||||
input-one:
|
||||
default: 'one'
|
||||
description: 'description one'
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: GITHUB_ACTION_REPOSITORY
|
||||
run: |
|
||||
set -x
|
||||
test "$GITHUB_ACTION_REPOSITORY" = root/action-for-context
|
||||
test "$GITHUB_ACTION_REPOSITORY" = "${{ env.GITHUB_ACTION_REPOSITORY }}"
|
||||
test "$GITHUB_ACTION_REPOSITORY" = "${{ github.ACTION_REPOSITORY }}"
|
||||
touch /srv/example/example-context/GITHUB_ACTION_REPOSITORY
|
||||
|
||||
- name: GITHUB_ACTION_PATH
|
||||
shell: bash
|
||||
run: |
|
||||
set -x
|
||||
[[ "$GITHUB_ACTION_PATH" =~ action-for-context@main$ ]]
|
||||
test "$GITHUB_ACTION_PATH" = "${{ github.ACTION_PATH }}"
|
||||
touch /srv/example/example-context/GITHUB_ACTION_PATH
|
1
actions/example-context/run.sh
Normal file
1
actions/example-context/run.sh
Normal file
|
@ -0,0 +1 @@
|
|||
forgejo-test-helper.sh run_workflow actions/example-$example $url root example-$example action-for-context $token
|
3
actions/example-context/setup.sh
Normal file
3
actions/example-context/setup.sh
Normal file
|
@ -0,0 +1,3 @@
|
|||
mkdir -p /srv/example/example-context
|
||||
|
||||
forgejo-test-helper.sh push actions/example-$example/action-for-context $url root action-for-context
|
|
@ -7,8 +7,16 @@ jobs:
|
|||
runs-on: docker
|
||||
container:
|
||||
image: code.forgejo.org/oci/debian:bookworm
|
||||
options: "--volume /srv/example-cron-volume:/srv/example-cron-volume"
|
||||
options: "--volume /srv/example:/srv/example"
|
||||
|
||||
steps:
|
||||
- name: save context
|
||||
run: |
|
||||
d=/srv/example/cron/contexts/$GITHUB_EVENT_NAME
|
||||
mkdir -p $d
|
||||
cat > $d/github <<'EOF'
|
||||
${{ toJSON(github) }}
|
||||
EOF
|
||||
|
||||
- run: |
|
||||
touch /srv/example-cron-volume/DONE
|
||||
touch /srv/example/cron-volume/DONE
|
||||
|
|
|
@ -7,7 +7,7 @@ forgejo-test-helper.sh push_workflow actions/example-$example $url root example-
|
|||
# See https://codeberg.org/forgejo/forgejo/pulls/1941 for more information
|
||||
#
|
||||
function verify_ref() {
|
||||
local ref=$(sqlite3 $DIR/forgejo-work-path/forgejo.db 'select ref from action_schedule')
|
||||
local ref=$(sqlite3 $DIR/forgejo-work-path/forgejo.db 'select ref from action_schedule')
|
||||
test "${ref##*/}" = "main"
|
||||
}
|
||||
verify_ref
|
||||
|
@ -16,7 +16,12 @@ forgejo-curl.sh api_json --data '{"new_branch_name":"zzzz"}' $api/repos/root/exa
|
|||
verify_ref
|
||||
|
||||
# cron runs once per minute, give it three minutes max before declaring failure
|
||||
if ! RETRY_DELAYS="30 30 30 30 30 30" forgejo.sh retry test -f /srv/example-cron-volume/DONE ; then
|
||||
if ! RETRY_DELAYS="30 30 30 30 30 30" forgejo.sh retry test -f /srv/example/cron-volume/DONE; then
|
||||
cat $FORGEJO_RUNNER_LOGS
|
||||
false
|
||||
fi
|
||||
|
||||
c=/srv/example/cron/contexts/schedule/github
|
||||
cat $c
|
||||
test "schedule" = "$(jq -r .event_name <$c)"
|
||||
test "schedule" = "$(jq -r .event.action <$c)"
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
rm -fr /srv/example-cron-volume
|
||||
mkdir -p /srv/example-cron-volume
|
||||
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload
|
||||
mkdir -p /srv/example/cron-volume
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
FROM code.forgejo.org/oci/debian:bookworm
|
||||
COPY entrypoint.sh /run/entrypoint.sh
|
||||
# if we rebuild, we should notice this file change
|
||||
COPY input.txt /run/input.txt
|
||||
ENTRYPOINT [ "/run/entrypoint.sh" ]
|
|
@ -0,0 +1,6 @@
|
|||
name: local docker action
|
||||
description: local docker action, build depends on "input.txt"
|
||||
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
3
actions/example-force-rebuild/.forgejo/local-docker-action/entrypoint.sh
Executable file
3
actions/example-force-rebuild/.forgejo/local-docker-action/entrypoint.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#! /usr/bin/env bash
|
||||
set -x
|
||||
exit "$(< /run/input.txt)"
|
|
@ -0,0 +1 @@
|
|||
this file will be filled by the test
|
10
actions/example-force-rebuild/.forgejo/workflows/test.yml
Normal file
10
actions/example-force-rebuild/.forgejo/workflows/test.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
on:
|
||||
push:
|
||||
jobs:
|
||||
test:
|
||||
runs-on: docker
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
- uses: ./.forgejo/local-docker-action
|
42
actions/example-force-rebuild/run.sh
Executable file
42
actions/example-force-rebuild/run.sh
Executable file
|
@ -0,0 +1,42 @@
|
|||
TMPDIR=$(mktemp -d)
|
||||
|
||||
trap "rm -fr $TMPDIR" EXIT
|
||||
|
||||
function setup_with_rebuild() {
|
||||
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config-with-rebuild.yml forgejo-runner.sh reload
|
||||
}
|
||||
|
||||
function setup_without_rebuild() {
|
||||
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config-without-rebuild.yml forgejo-runner.sh reload
|
||||
}
|
||||
|
||||
function run() {
|
||||
local dir="$1"
|
||||
local expected="$2"
|
||||
local repo=root/example-$example
|
||||
forgejo-test-helper.sh push_workflow $dir $url root example-$example setup-forgejo $token
|
||||
sha=$(forgejo-test-helper.sh branch_tip $url $repo main)
|
||||
forgejo-test-helper.sh wait_$expected $url $repo $sha
|
||||
}
|
||||
|
||||
function main() {
|
||||
local dir=$TMPDIR/repository
|
||||
cp -a $EXAMPLE_DIR $dir
|
||||
|
||||
# set up passing docker action
|
||||
echo "0" >$dir/.forgejo/local-docker-action/input.txt
|
||||
setup_with_rebuild
|
||||
run $dir success
|
||||
|
||||
# change docker action to fail
|
||||
echo "1" >$dir/.forgejo/local-docker-action/input.txt
|
||||
# ... but without a rebuild, it should still pass
|
||||
setup_without_rebuild
|
||||
run $dir success
|
||||
|
||||
# now the action should fail
|
||||
setup_with_rebuild
|
||||
run $dir failure
|
||||
}
|
||||
|
||||
main
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
log:
|
||||
level: info
|
||||
level: debug
|
||||
|
||||
runner:
|
||||
file: .runner
|
||||
|
@ -10,7 +9,7 @@ runner:
|
|||
insecure: false
|
||||
fetch_timeout: 5s
|
||||
fetch_interval: 2s
|
||||
labels: ["docker:docker://code.forgejo.org/oci/node:16-bullseye"]
|
||||
labels: ["docker:docker://code.forgejo.org/oci/node:20-bookworm"]
|
||||
|
||||
cache:
|
||||
enabled: false
|
||||
|
@ -19,12 +18,13 @@ cache:
|
|||
port: 0
|
||||
|
||||
container:
|
||||
network: ""
|
||||
network: "bridge"
|
||||
privileged: false
|
||||
options:
|
||||
workdir_parent:
|
||||
valid_volumes: ["/srv/example-cron-volume"]
|
||||
valid_volumes: ["/srv/example"]
|
||||
docker_host: ""
|
||||
force_rebuild: true
|
||||
|
||||
host:
|
||||
workdir_parent:
|
|
@ -0,0 +1,30 @@
|
|||
log:
|
||||
level: debug
|
||||
|
||||
runner:
|
||||
file: .runner
|
||||
capacity: 1
|
||||
env_file: .env
|
||||
timeout: 3h
|
||||
insecure: false
|
||||
fetch_timeout: 5s
|
||||
fetch_interval: 2s
|
||||
labels: ["docker:docker://code.forgejo.org/oci/node:20-bookworm"]
|
||||
|
||||
cache:
|
||||
enabled: false
|
||||
dir: ""
|
||||
host: ""
|
||||
port: 0
|
||||
|
||||
container:
|
||||
network: "bridge"
|
||||
privileged: false
|
||||
options:
|
||||
workdir_parent:
|
||||
valid_volumes: ["/srv/example"]
|
||||
docker_host: ""
|
||||
force_rebuild: false
|
||||
|
||||
host:
|
||||
workdir_parent:
|
1
actions/example-force-rebuild/teardown.sh
Executable file
1
actions/example-force-rebuild/teardown.sh
Executable file
|
@ -0,0 +1 @@
|
|||
forgejo-runner.sh reload
|
|
@ -1,9 +1,3 @@
|
|||
#
|
||||
# As of Forgejo v1.20 running this example would require using the web
|
||||
# endpoints because there is no API to do the same.
|
||||
#
|
||||
# It was manually tested to **not work** with Forgejo v1.21 & runner 3.0.1
|
||||
#
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
|
|
|
@ -13,4 +13,10 @@ outputs:
|
|||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: GITHUB_ACTION_PATH
|
||||
run: |
|
||||
set -x
|
||||
test "$(basename $GITHUB_ACTION_PATH)" = local-action
|
||||
test "$GITHUB_ACTION_PATH" = "${{ env.GITHUB_ACTION_PATH }}"
|
||||
|
||||
- run: echo key=${{ inputs.input-two-required }} >> $GITHUB_OUTPUT
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
on:
|
||||
schedule:
|
||||
- cron: '* * * * *'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ${{ vars.TEST_SCHEDULE_RUNSON }}
|
||||
container:
|
||||
image: code.forgejo.org/oci/debian:bookworm
|
||||
options: "--volume /srv/example:/srv/example"
|
||||
|
||||
steps:
|
||||
- name: save context
|
||||
run: |
|
||||
d=/srv/example/post-7-0-schedule/contexts/$GITHUB_EVENT_NAME
|
||||
mkdir -p $d
|
||||
cat > $d/github <<'EOF'
|
||||
${{ toJSON(github) }}
|
||||
EOF
|
||||
|
||||
- run: |
|
||||
echo "TEST_SCHEDULE_RUNSON=${{ vars.TEST_SCHEDULE_RUNSON }}"
|
||||
touch /srv/example/post-7-0-schedule-volume/DONE
|
30
actions/example-post-7-0-schedule/run.sh
Executable file
30
actions/example-post-7-0-schedule/run.sh
Executable file
|
@ -0,0 +1,30 @@
|
|||
forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token
|
||||
|
||||
forgejo-curl.sh web -X POST http://${HOST_PORT}/admin/actions/variables/1/delete || true
|
||||
forgejo-curl.sh web --form name=TEST_SCHEDULE_RUNSON --form data=docker http://${HOST_PORT}/admin/actions/variables/new
|
||||
|
||||
#
|
||||
# Verify that creating a new branch with the same SHA as the default branch
|
||||
# does not change the ref associated with the schedule
|
||||
#
|
||||
# See https://codeberg.org/forgejo/forgejo/pulls/1941 for more information
|
||||
#
|
||||
function verify_ref() {
|
||||
local ref=$(sqlite3 $DIR/forgejo-work-path/forgejo.db 'select ref from action_schedule')
|
||||
test "${ref##*/}" = "main"
|
||||
}
|
||||
verify_ref
|
||||
api=$url/api/v1
|
||||
forgejo-curl.sh api_json --data '{"new_branch_name":"zzzz"}' $api/repos/root/example-post-7-0-schedule/branches
|
||||
verify_ref
|
||||
|
||||
# runs once per minute, give it three minutes max before declaring failure
|
||||
if ! RETRY_DELAYS="30 30 30 30 30 30" forgejo.sh retry test -f /srv/example/post-7-0-schedule-volume/DONE; then
|
||||
cat $FORGEJO_RUNNER_LOGS
|
||||
false
|
||||
fi
|
||||
|
||||
c=/srv/example/post-7-0-schedule/contexts/schedule/github
|
||||
cat $c
|
||||
test "schedule" = "$(jq -r .event_name <$c)"
|
||||
test "schedule" = "$(jq -r .event.action <$c)"
|
1
actions/example-post-7-0-schedule/setup.sh
Executable file
1
actions/example-post-7-0-schedule/setup.sh
Executable file
|
@ -0,0 +1 @@
|
|||
mkdir -p /srv/example/post-7-0-schedule-volume
|
|
@ -10,7 +10,7 @@ jobs:
|
|||
runs-on: docker
|
||||
container:
|
||||
image: code.forgejo.org/oci/node:20-bookworm
|
||||
options: "--volume /srv/example-pull-request:/srv/example-pull-request"
|
||||
options: "--volume /srv/example:/srv/example"
|
||||
|
||||
steps:
|
||||
- name: setup
|
||||
|
@ -33,6 +33,24 @@ jobs:
|
|||
echo value=true >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
# See also actions/example-context/.forgejo/workflows/test.yml
|
||||
- name: env.GITHUB_BASE_REF
|
||||
run: |
|
||||
set -x
|
||||
test "$GITHUB_BASE_REF" = main
|
||||
test "$GITHUB_BASE_REF" = "${{ env.GITHUB_BASE_REF }}"
|
||||
|
||||
# See also actions/example-context/.forgejo/workflows/test.yml
|
||||
- name: env.GITHUB_HEAD_REF
|
||||
run: |
|
||||
set -x
|
||||
if ${{ steps.forked.outputs.value }} ; then
|
||||
test "$GITHUB_HEAD_REF" = main
|
||||
else
|
||||
test "$GITHUB_HEAD_REF" = other
|
||||
fi
|
||||
test "$GITHUB_HEAD_REF" = "${{ env.GITHUB_HEAD_REF }}"
|
||||
|
||||
- name: secrets
|
||||
shell: bash
|
||||
run: |
|
||||
|
@ -115,10 +133,10 @@ jobs:
|
|||
|
||||
- name: save event
|
||||
run: |
|
||||
d=/srv/example-pull-request/${{ github.event.pull_request.head.repo.owner.username }}/$GITHUB_EVENT_NAME/${{ github.event.action }}
|
||||
d=/srv/example/pull-request/contexts/${{ github.event.pull_request.head.repo.owner.username }}/$GITHUB_EVENT_NAME
|
||||
mkdir -p $d
|
||||
cat > $d/event <<'EOF'
|
||||
${{ toJSON(github.event) }}
|
||||
cat > $d/github <<'EOF'
|
||||
${{ toJSON(github) }}
|
||||
EOF
|
||||
|
||||
- uses: https://code.forgejo.org/actions/checkout@v4
|
||||
|
|
11
actions/example-pull-request/assert-contexts.sh
Executable file
11
actions/example-pull-request/assert-contexts.sh
Executable file
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
c=$d/contexts
|
||||
|
||||
test opened = "$(jq -r .event.action <$c/fork-org/pull_request/github)"
|
||||
test opened = "$(jq -r .event.action <$c/fork-org/pull_request_target/github)"
|
||||
|
||||
test opened = "$(jq -r .event.action <$c/root/pull_request/github)"
|
||||
test opened = "$(jq -r .event.action <$c/root/pull_request_target/github)"
|
|
@ -1,8 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
test -d $d/fork-org/pull_request/opened
|
||||
test -d $d/fork-org/pull_request_target/opened
|
||||
test -d $d/root/pull_request/opened
|
||||
test -d $d/root/pull_request_target/opened
|
|
@ -1,59 +1,56 @@
|
|||
api=$url/api/v1
|
||||
export d=/srv/example-pull-request
|
||||
export d=/srv/example/pull-request
|
||||
|
||||
PROOF='some proof'
|
||||
|
||||
function setup() {
|
||||
function main() {
|
||||
mkdir -p $d
|
||||
|
||||
forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token
|
||||
|
||||
forgejo-curl.sh api_json --data-raw '{"username":"fork-org"}' $api/orgs
|
||||
forgejo-curl.sh api_json --data-raw '{"organization":"fork-org"}' $api/repos/root/example-pull-request/forks
|
||||
forgejo-curl.sh api_json -X PUT --data-raw '{"data":"AAAA"}' $api/repos/root/example-pull-request/actions/secrets/SECRET
|
||||
|
||||
|
||||
(
|
||||
cd $d
|
||||
git clone $url/fork-org/example-pull-request fork
|
||||
cd fork
|
||||
git config user.email root@example.com
|
||||
git config user.name username
|
||||
echo fork $PROOF >> README
|
||||
touch file-unique-to-the-pr-branch
|
||||
git add .
|
||||
git commit -m 'fork change'
|
||||
git push
|
||||
cd $d
|
||||
git clone $url/fork-org/example-pull-request fork
|
||||
cd fork
|
||||
git config user.email root@example.com
|
||||
git config user.name username
|
||||
echo fork $PROOF >>README
|
||||
touch file-unique-to-the-pr-branch
|
||||
git add .
|
||||
git commit -m 'fork change'
|
||||
git push
|
||||
)
|
||||
|
||||
forgejo.sh retry forgejo-curl.sh api_json --data-raw '{"title":"PR from fork","base":"main","head":"fork-org:main"}' $api/repos/root/example-pull-request/pulls
|
||||
|
||||
(
|
||||
cd $d
|
||||
git clone $url/root/example-pull-request
|
||||
cd example-pull-request
|
||||
git checkout -b other
|
||||
git config user.email root@example.com
|
||||
git config user.name username
|
||||
touch file-unique-to-the-pr-branch
|
||||
echo other $PROOF >> README
|
||||
git add .
|
||||
git commit -m 'other change'
|
||||
git push --force -u origin other
|
||||
cd $d
|
||||
git clone $url/root/example-pull-request
|
||||
cd example-pull-request
|
||||
git checkout -b other
|
||||
git config user.email root@example.com
|
||||
git config user.name username
|
||||
touch file-unique-to-the-pr-branch
|
||||
echo other $PROOF >>README
|
||||
git add .
|
||||
git commit -m 'other change'
|
||||
git push --force -u origin other
|
||||
)
|
||||
|
||||
forgejo.sh retry forgejo-curl.sh api_json --data-raw '{"title":"PR same repo","base":"main","head":"other"}' $api/repos/root/example-pull-request/pulls
|
||||
|
||||
export RETRY_DELAYS="60 60 60 60 60 60 60"
|
||||
for assert in $EXAMPLE_DIR/assert-*.sh ; do
|
||||
if ! forgejo.sh retry $assert ; then
|
||||
find $d
|
||||
cat $FORGEJO_RUNNER_LOGS
|
||||
false
|
||||
fi
|
||||
for assert in $EXAMPLE_DIR/assert-*.sh; do
|
||||
if ! forgejo.sh retry $assert; then
|
||||
find $d
|
||||
sed -e 's/^/[RUNNER LOGS]/' <$FORGEJO_RUNNER_LOGS
|
||||
false
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function main() {
|
||||
setup
|
||||
}
|
||||
|
||||
main
|
||||
|
|
|
@ -1,8 +1 @@
|
|||
if test $(id -u) != 0 ; then
|
||||
SUDO=sudo
|
||||
fi
|
||||
|
||||
$SUDO rm -fr /srv/example-pull-request/{root,fork-org}
|
||||
rm -fr /srv/example-pull-request
|
||||
mkdir -p /srv/example-pull-request
|
||||
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload
|
||||
mkdir -p /srv/example/pull-request
|
||||
|
|
|
@ -11,8 +11,8 @@ forgejo-test-helper.sh wait_running $url $repo $sha
|
|||
#
|
||||
# push to the same branch
|
||||
#
|
||||
forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token
|
||||
forgejo-test-helper.sh push_workflow actions/example-echo $url root example-$example setup-forgejo $token
|
||||
#
|
||||
# wait for the workflow to be canceld as a result of the previous push
|
||||
# wait for the workflow to be canceled as a result of the previous push
|
||||
#
|
||||
forgejo-test-helper.sh wait_failure $url $repo $sha 'Has been cancelled'
|
||||
|
|
23
actions/example-push/.forgejo/workflows/test.yml
Normal file
23
actions/example-push/.forgejo/workflows/test.yml
Normal file
|
@ -0,0 +1,23 @@
|
|||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'mai*'
|
||||
paths:
|
||||
- '**/test.yml'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: code.forgejo.org/oci/node:20-bookworm
|
||||
volumes:
|
||||
- /srv/example:/srv/example
|
||||
steps:
|
||||
|
||||
- name: save event
|
||||
run: |
|
||||
d=/srv/example/push/contexts/$GITHUB_EVENT_NAME
|
||||
mkdir -p $d
|
||||
cat > $d/github <<'EOF'
|
||||
${{ toJSON(github) }}
|
||||
EOF
|
|
@ -0,0 +1,15 @@
|
|||
on:
|
||||
schedule:
|
||||
- cron: "* * * * *"
|
||||
jobs:
|
||||
test:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: code.forgejo.org/oci/debian:bookworm
|
||||
volumes:
|
||||
- /srv/example:/srv/example
|
||||
steps:
|
||||
- run: |
|
||||
while ! [ -f /srv/example/schedule-noncancel/PUSHED ]; do
|
||||
sleep 3
|
||||
done
|
99
actions/example-schedule-noncancel/run.sh
Executable file
99
actions/example-schedule-noncancel/run.sh
Executable file
|
@ -0,0 +1,99 @@
|
|||
repo=root/example-$example
|
||||
#
|
||||
# delete the repository
|
||||
#
|
||||
api=$url/api/v1
|
||||
if forgejo-curl.sh api_json -X GET $api/repos/root/example-$example; then
|
||||
forgejo-curl.sh api_json -X DELETE $api/repos/root/example-$example
|
||||
fi
|
||||
|
||||
#
|
||||
# push the repository
|
||||
#
|
||||
forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token
|
||||
|
||||
#
|
||||
# get the run id of the workflow that just started
|
||||
#
|
||||
getScheduleRun() {
|
||||
rm -f $DIR/forgejo-work-path/forgejo.copy.db
|
||||
cp $DIR/forgejo-work-path/forgejo.db $DIR/forgejo-work-path/forgejo.copy.db
|
||||
sqlite3 $DIR/forgejo-work-path/forgejo.copy.db \
|
||||
"pragma busy_timeout = 5000; \
|
||||
select action_run.id \
|
||||
from action_run \
|
||||
inner join action_schedule on action_run.schedule_id = action_schedule.id \
|
||||
inner join repository on action_schedule.repo_id = repository.id \
|
||||
where repository.name = 'example-schedule-noncancel' \
|
||||
order by action_run.created desc limit 1" | sed '2q;d'
|
||||
}
|
||||
|
||||
run_id=$(getScheduleRun)
|
||||
while [ -z $run_id ]; do
|
||||
echo waiting 5...
|
||||
sleep 5
|
||||
run_id=$(getScheduleRun)
|
||||
done
|
||||
|
||||
echo Schedule run id: $run_id
|
||||
|
||||
#
|
||||
# Wait for it to be started
|
||||
#
|
||||
checkStarted() {
|
||||
rm -f $DIR/forgejo-work-path/forgejo.copy.db
|
||||
cp $DIR/forgejo-work-path/forgejo.db $DIR/forgejo-work-path/forgejo.copy.db
|
||||
sqlite3 $DIR/forgejo-work-path/forgejo.copy.db \
|
||||
"pragma busy_timeout = 5000; \
|
||||
select id \
|
||||
from action_run \
|
||||
where id = $run_id \
|
||||
and started is not null" | sed '2q;d'
|
||||
}
|
||||
|
||||
started_check=$(checkStarted)
|
||||
while [ -z $started_check ]; do
|
||||
echo waiting 2...
|
||||
sleep 2
|
||||
started_check=$(checkStarted)
|
||||
done
|
||||
|
||||
echo Run has started
|
||||
echo Push to repo again
|
||||
|
||||
#
|
||||
# Push to the repo again
|
||||
#
|
||||
forgejo-test-helper.sh push_workflow actions/example-echo $url root example-$example setup-forgejo $token
|
||||
|
||||
echo Signal to the workflow that the push has happened
|
||||
mkdir -p /srv/example/schedule-noncancel
|
||||
touch /srv/example/schedule-noncancel/PUSHED
|
||||
|
||||
#
|
||||
# Wait for the workflow to finish anyway
|
||||
#
|
||||
echo Wait for workflow to finish
|
||||
|
||||
checkFinished() {
|
||||
rm -f $DIR/forgejo-work-path/forgejo.copy.db
|
||||
cp $DIR/forgejo-work-path/forgejo.db $DIR/forgejo-work-path/forgejo.copy.db
|
||||
sqlite3 $DIR/forgejo-work-path/forgejo.copy.db \
|
||||
"pragma busy_timeout = 5000; \
|
||||
select status \
|
||||
from action_run \
|
||||
where id = $run_id \
|
||||
and (status != 6 and status != 5)" | sed '2q;d'
|
||||
}
|
||||
|
||||
finished_status=$(checkFinished)
|
||||
while [ -z $finished_status ]; do
|
||||
echo waiting 5...
|
||||
sleep 5
|
||||
finished_status=$(checkFinished)
|
||||
done
|
||||
|
||||
echo Workflow finished.
|
||||
rm -f $DIR/forgejo-work-path/forgejo.copy.db
|
||||
|
||||
test $finished_status = 1
|
4
actions/example-schedule-noncancel/teardown.sh
Normal file
4
actions/example-schedule-noncancel/teardown.sh
Normal file
|
@ -0,0 +1,4 @@
|
|||
#
|
||||
# this will effectively discard any linger workflow so they do not interfere with other tests
|
||||
#
|
||||
forgejo-runner.sh reload
|
|
@ -2,7 +2,23 @@ on: [push]
|
|||
|
||||
jobs:
|
||||
#
|
||||
# No volume involved
|
||||
# No volume involved & the container is implicit
|
||||
#
|
||||
simple-no-container:
|
||||
runs-on: docker
|
||||
services:
|
||||
pgsql:
|
||||
image: code.forgejo.org/oci/postgres:15
|
||||
env:
|
||||
POSTGRES_DB: test
|
||||
POSTGRES_PASSWORD: postgres
|
||||
steps:
|
||||
- run: |
|
||||
apt-get update -qq
|
||||
apt-get install -y -qq postgresql-client
|
||||
PGPASSWORD=postgres psql -h pgsql -U postgres -c '\dt' test
|
||||
#
|
||||
# No volume involved & the container is explicit
|
||||
#
|
||||
simple:
|
||||
runs-on: docker
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
log:
|
||||
level: info
|
||||
level: debug
|
||||
|
||||
runner:
|
||||
file: .runner
|
||||
|
@ -10,7 +10,7 @@ runner:
|
|||
insecure: false
|
||||
fetch_timeout: 5s
|
||||
fetch_interval: 2s
|
||||
labels: ["docker:docker://code.forgejo.org/oci/node:16-bullseye"]
|
||||
labels: ["docker:docker://code.forgejo.org/oci/node:20-bookworm"]
|
||||
|
||||
cache:
|
||||
enabled: false
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
> /srv/example-service-volume-valid
|
||||
> /srv/example-service-volume-invalid
|
||||
>/srv/example-service-volume-valid
|
||||
>/srv/example-service-volume-invalid
|
||||
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload
|
||||
|
|
21
actions/example-tag/.forgejo/workflows/test.yml
Normal file
21
actions/example-tag/.forgejo/workflows/test.yml
Normal file
|
@ -0,0 +1,21 @@
|
|||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: code.forgejo.org/oci/node:20-bookworm
|
||||
volumes:
|
||||
- /srv/example:/srv/example
|
||||
steps:
|
||||
|
||||
- name: save event
|
||||
run: |
|
||||
d=/srv/example/tag/contexts/$GITHUB_EVENT_NAME
|
||||
mkdir -p $d
|
||||
cat > $d/github <<'EOF'
|
||||
${{ toJSON(github) }}
|
||||
EOF
|
19
actions/example-tag/run.sh
Executable file
19
actions/example-tag/run.sh
Executable file
|
@ -0,0 +1,19 @@
|
|||
export d=/srv/example/tag
|
||||
|
||||
function main() {
|
||||
mkdir -p $d
|
||||
|
||||
local repo=root/example-$example
|
||||
|
||||
forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token
|
||||
local sha=$(forgejo-test-helper.sh branch_tip $url $repo main)
|
||||
|
||||
local api=$url/api/v1
|
||||
forgejo-curl.sh api_json --data-raw '{"tag_name":"v1.1","target":"'$sha'"}' $api/repos/$repo/tags
|
||||
|
||||
forgejo-test-helper.sh wait_success $url $repo $sha
|
||||
|
||||
test -f /srv/example/tag/contexts/push/github
|
||||
}
|
||||
|
||||
main
|
10
actions/example-with-docker-host/.forgejo/workflows/test.yml
Normal file
10
actions/example-with-docker-host/.forgejo/workflows/test.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: code.forgejo.org/oci/docker:cli
|
||||
steps:
|
||||
- run: ls -l /var/run/docker.sock
|
||||
- run: docker ps
|
30
actions/example-with-docker-host/runner-config.yaml
Normal file
30
actions/example-with-docker-host/runner-config.yaml
Normal file
|
@ -0,0 +1,30 @@
|
|||
|
||||
log:
|
||||
level: debug
|
||||
|
||||
runner:
|
||||
file: .runner
|
||||
capacity: 1
|
||||
env_file: .env
|
||||
timeout: 3h
|
||||
insecure: false
|
||||
fetch_timeout: 5s
|
||||
fetch_interval: 2s
|
||||
labels: ["docker:docker://code.forgejo.org/oci/node:20-bookworm"]
|
||||
|
||||
cache:
|
||||
enabled: true
|
||||
dir: "/srv/example/cache"
|
||||
host: ""
|
||||
port: 0
|
||||
|
||||
container:
|
||||
network: "bridge"
|
||||
privileged: false
|
||||
options:
|
||||
workdir_parent:
|
||||
valid_volumes: ["/srv/example"]
|
||||
docker_host: "unix:///var/run/docker.sock"
|
||||
|
||||
host:
|
||||
workdir_parent:
|
1
actions/example-with-docker-host/setup.sh
Executable file
1
actions/example-with-docker-host/setup.sh
Executable file
|
@ -0,0 +1 @@
|
|||
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload
|
1
actions/example-with-docker-host/teardown.sh
Executable file
1
actions/example-with-docker-host/teardown.sh
Executable file
|
@ -0,0 +1 @@
|
|||
forgejo-runner.sh reload
|
|
@ -0,0 +1,10 @@
|
|||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: code.forgejo.org/oci/docker:cli
|
||||
steps:
|
||||
- run: ls -l /var/run/docker.sock
|
||||
- run: docker ps
|
30
actions/example-with-docker-socket/runner-config.yaml
Normal file
30
actions/example-with-docker-socket/runner-config.yaml
Normal file
|
@ -0,0 +1,30 @@
|
|||
|
||||
log:
|
||||
level: debug
|
||||
|
||||
runner:
|
||||
file: .runner
|
||||
capacity: 1
|
||||
env_file: .env
|
||||
timeout: 3h
|
||||
insecure: false
|
||||
fetch_timeout: 5s
|
||||
fetch_interval: 2s
|
||||
labels: ["docker:docker://code.forgejo.org/oci/node:20-bookworm"]
|
||||
|
||||
cache:
|
||||
enabled: true
|
||||
dir: "/srv/example/cache"
|
||||
host: ""
|
||||
port: 0
|
||||
|
||||
container:
|
||||
network: "bridge"
|
||||
privileged: false
|
||||
options:
|
||||
workdir_parent:
|
||||
valid_volumes: ["/srv/example"]
|
||||
docker_host: "automount"
|
||||
|
||||
host:
|
||||
workdir_parent:
|
1
actions/example-with-docker-socket/setup.sh
Executable file
1
actions/example-with-docker-socket/setup.sh
Executable file
|
@ -0,0 +1 @@
|
|||
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload
|
1
actions/example-with-docker-socket/teardown.sh
Executable file
1
actions/example-with-docker-socket/teardown.sh
Executable file
|
@ -0,0 +1 @@
|
|||
forgejo-runner.sh reload
|
11
actions/example-with-docker-tcp/.forgejo/workflows/test.yml
Normal file
11
actions/example-with-docker-tcp/.forgejo/workflows/test.yml
Normal file
|
@ -0,0 +1,11 @@
|
|||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: code.forgejo.org/oci/node:20-bookworm
|
||||
steps:
|
||||
- run: |
|
||||
! test -e /var/run/docker.sock
|
||||
! env | grep DOCKER_HOST
|
30
actions/example-with-docker-tcp/runner-config.yaml
Normal file
30
actions/example-with-docker-tcp/runner-config.yaml
Normal file
|
@ -0,0 +1,30 @@
|
|||
|
||||
log:
|
||||
level: debug
|
||||
|
||||
runner:
|
||||
file: .runner
|
||||
capacity: 1
|
||||
env_file: .env
|
||||
timeout: 3h
|
||||
insecure: false
|
||||
fetch_timeout: 5s
|
||||
fetch_interval: 2s
|
||||
labels: ["docker:docker://code.forgejo.org/oci/node:20-bookworm"]
|
||||
|
||||
cache:
|
||||
enabled: true
|
||||
dir: "/srv/example/cache"
|
||||
host: ""
|
||||
port: 0
|
||||
|
||||
container:
|
||||
network: "bridge"
|
||||
privileged: false
|
||||
options:
|
||||
workdir_parent:
|
||||
valid_volumes: ["/srv/example"]
|
||||
docker_host: "tcp://127.0.0.1:2375"
|
||||
|
||||
host:
|
||||
workdir_parent:
|
1
actions/example-with-docker-tcp/setup.sh
Executable file
1
actions/example-with-docker-tcp/setup.sh
Executable file
|
@ -0,0 +1 @@
|
|||
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload
|
1
actions/example-with-docker-tcp/teardown.sh
Executable file
1
actions/example-with-docker-tcp/teardown.sh
Executable file
|
@ -0,0 +1 @@
|
|||
forgejo-runner.sh reload
|
|
@ -0,0 +1,6 @@
|
|||
on: [push]
|
||||
jobs:
|
||||
test:
|
||||
runs-on: docker
|
||||
steps:
|
||||
- run: "! test -e /var/run/docker.sock"
|
|
@ -0,0 +1,57 @@
|
|||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
logLevel:
|
||||
description: 'Log Level'
|
||||
required: true
|
||||
default: 'warning'
|
||||
type: choice
|
||||
options:
|
||||
- info
|
||||
- warning
|
||||
- debug
|
||||
tags:
|
||||
description: 'Test scenario tags'
|
||||
required: false
|
||||
type: boolean
|
||||
boolean_default_true:
|
||||
description: 'Test scenario tags'
|
||||
required: true
|
||||
type: boolean
|
||||
default: true
|
||||
boolean_default_false:
|
||||
description: 'Test scenario tags'
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
number1_default:
|
||||
description: 'Number w. default'
|
||||
default: '100'
|
||||
type: number
|
||||
number2:
|
||||
description: 'Number w/o. default'
|
||||
type: number
|
||||
string1_default:
|
||||
description: 'String w. default'
|
||||
default: 'Hello world'
|
||||
type: string
|
||||
string2:
|
||||
description: 'String w/o. default'
|
||||
required: true
|
||||
type: string
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: docker
|
||||
container:
|
||||
image: code.forgejo.org/oci/debian:bookworm
|
||||
options: "--volume /srv/example:/srv/example"
|
||||
|
||||
steps:
|
||||
- name: save and display context
|
||||
run: |
|
||||
d=/srv/example/workflow-dispatch/contexts/$GITHUB_EVENT_NAME
|
||||
mkdir -p $d
|
||||
tee $d/github <<'EOF'
|
||||
${{ toJSON(github) }}
|
||||
EOF
|
62
actions/example-workflow-dispatch/run.sh
Executable file
62
actions/example-workflow-dispatch/run.sh
Executable file
|
@ -0,0 +1,62 @@
|
|||
TMPDIR=$(mktemp -d)
|
||||
|
||||
trap "rm -fr $TMPDIR" EXIT
|
||||
|
||||
source $EXAMPLE_DIR/../../lib/lib.sh
|
||||
|
||||
export d=/srv/example/tag
|
||||
context=/srv/example/workflow-dispatch/contexts/workflow_dispatch/github
|
||||
api=$url/api/v1
|
||||
repo=root/example-$example
|
||||
|
||||
function context_wait() {
|
||||
if ! forgejo.sh retry test -f $context; then
|
||||
cat "$FORGEJO_RUNNER_LOGS"
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
function verify_required() {
|
||||
local actual=$(forgejo-curl.sh api_json -w '%{http_code}' --data '{"ref":"main","inputs":{}}' $api/repos/$repo/actions/workflows/test.yml/dispatches)
|
||||
local expected=400
|
||||
if test "$actual" != $expected; then
|
||||
log_info "dispatch is expected to fail with status $expected because of string2 is a required value but got status $actual instead"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function verify_inputs() {
|
||||
local inputs='{"string2":"value2"}'
|
||||
forgejo-curl.sh api_json --data '{"ref":"main","inputs":'$inputs'}' $api/repos/$repo/actions/workflows/test.yml/dispatches
|
||||
cat >$TMPDIR/expected <<'EOF'
|
||||
{
|
||||
"boolean_default_false": "false",
|
||||
"boolean_default_true": "true",
|
||||
"logLevel": "warning",
|
||||
"number1_default": "100",
|
||||
"string1_default": "Hello world",
|
||||
"string2": "value2"
|
||||
}
|
||||
EOF
|
||||
}
|
||||
|
||||
function run_tests() {
|
||||
verify_required
|
||||
|
||||
npm --silent install json-diff
|
||||
verify_inputs
|
||||
context_wait
|
||||
node_modules/.bin/json-diff <(jq .event.inputs <$context) $TMPDIR/expected
|
||||
}
|
||||
|
||||
function main() {
|
||||
mkdir -p $d
|
||||
|
||||
forgejo-test-helper.sh push_workflow actions/example-$example $url root example-$example setup-forgejo $token
|
||||
|
||||
run_tests
|
||||
|
||||
test "workflow_dispatch" = "$(jq -r .event_name <$context)"
|
||||
}
|
||||
|
||||
main
|
1
actions/example-workflow-dispatch/setup.sh
Executable file
1
actions/example-workflow-dispatch/setup.sh
Executable file
|
@ -0,0 +1 @@
|
|||
mkdir -p /srv/example/workflow-dispatch
|
|
@ -1,96 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
function run() {
|
||||
local example=$1
|
||||
|
||||
export example
|
||||
export EXAMPLE_DIR=$(pwd)/actions/example-$example
|
||||
|
||||
if test -f $EXAMPLE_DIR/setup.sh ; then
|
||||
echo "============================ SETUP example-$example ==================="
|
||||
bash -ex $EXAMPLE_DIR/setup.sh || return 1
|
||||
fi
|
||||
|
||||
if test -f $EXAMPLE_DIR/run.sh ; then
|
||||
echo "============================ RUN example-$example ==================="
|
||||
bash -ex $EXAMPLE_DIR/run.sh || return 1
|
||||
else
|
||||
forgejo-test-helper.sh run_workflow actions/example-$example $url root example-$example setup-forgejo $token || return 1
|
||||
fi
|
||||
|
||||
if test -f $EXAMPLE_DIR/teardown.sh ; then
|
||||
echo "============================ TEARDOWN example-$example ==================="
|
||||
bash -ex $EXAMPLE_DIR/teardown.sh || return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function examples_v1_20() {
|
||||
echo 'echo checkout service container expression local-action docker-action if if-fail'
|
||||
}
|
||||
|
||||
function examples_v1_21() {
|
||||
# keep "cron" last otherwise it will linger and pollute the following runs
|
||||
echo 'echo push-cancel artifacts service checkout pull-request container expression local-action docker-action if if-fail cron'
|
||||
}
|
||||
|
||||
function examples_v1_22() {
|
||||
examples_v1_21
|
||||
}
|
||||
|
||||
function setup() {
|
||||
local binary=$1
|
||||
forgejo-binary.sh setup root admin1234 $binary
|
||||
forgejo-runner.sh setup
|
||||
}
|
||||
|
||||
function teardown() {
|
||||
forgejo-curl.sh logout
|
||||
forgejo-runner.sh teardown
|
||||
forgejo-binary.sh teardown
|
||||
}
|
||||
|
||||
function main() {
|
||||
local binary="$1"
|
||||
shift
|
||||
export version="$1"
|
||||
shift
|
||||
|
||||
export DOT=$DIR/forgejo-curl
|
||||
|
||||
teardown
|
||||
|
||||
if test "$#" = 0 ; then
|
||||
examples=$(examples_$version)
|
||||
else
|
||||
examples="$@"
|
||||
fi
|
||||
|
||||
if test "$examples" = "none" ; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
setup $binary
|
||||
|
||||
if ! test -f "$DIR/forgejo-auth-url" ; then
|
||||
echo "DIR=$DIR must be a directory with a forgejo-auth-url file"
|
||||
fi
|
||||
|
||||
export FORGEJO_RUNNER_LOGS=$DIR/forgejo-runner.log
|
||||
export url=$(cat $DIR/forgejo-auth-url)
|
||||
export token=$(cat $DIR/forgejo-token)
|
||||
|
||||
for example in $examples ; do
|
||||
echo "======================== BEGIN example-$example ==================="
|
||||
if ! time run $example >& /tmp/run.out ; then
|
||||
cat /tmp/run.out
|
||||
echo "======================== FAIL example-$example ==================="
|
||||
sleep 5 # hack for Forgejo v1.21 to workaround a bug by which the last lines of the output are moved to the next step
|
||||
false
|
||||
fi
|
||||
echo "======================== END example-$example ==================="
|
||||
done
|
||||
}
|
||||
|
||||
main "$@"
|
|
@ -1,6 +1,5 @@
|
|||
|
||||
log:
|
||||
level: info
|
||||
level: debug
|
||||
|
||||
runner:
|
||||
file: .runner
|
||||
|
@ -23,7 +22,7 @@ container:
|
|||
privileged: false
|
||||
options:
|
||||
workdir_parent:
|
||||
valid_volumes: ["/srv/example-pull-request"]
|
||||
valid_volumes: ["/srv/example"]
|
||||
docker_host: ""
|
||||
|
||||
host:
|
15
end-to-end.sh
Executable file
15
end-to-end.sh
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
SELF_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
SELF="${BASH_SOURCE[0]}"
|
||||
source $SELF_DIR/lib/lib.sh
|
||||
|
||||
source $SELF_DIR/federation/federation.sh
|
||||
source $SELF_DIR/actions/actions.sh
|
||||
source $SELF_DIR/forgejo/fixtures.sh
|
||||
source $SELF_DIR/storage/storage.sh
|
||||
source $SELF_DIR/upgrade/upgrade.sh
|
||||
source $SELF_DIR/packages/packages.sh
|
||||
|
||||
"$@"
|
33
federation/ONE-app.ini
Normal file
33
federation/ONE-app.ini
Normal file
|
@ -0,0 +1,33 @@
|
|||
RUN_MODE = prod
|
||||
WORK_PATH = forgejo-ONE
|
||||
|
||||
[server]
|
||||
APP_DATA_PATH = ${WORK_PATH}/data
|
||||
DOMAIN = ${IP}
|
||||
HTTP_PORT = 3001
|
||||
SSH_LISTEN_PORT = 2201
|
||||
|
||||
[queue]
|
||||
TYPE = immediate
|
||||
|
||||
[database]
|
||||
DB_TYPE = sqlite3
|
||||
PATH = ${WORK_PATH}/forgejo.db
|
||||
|
||||
[log]
|
||||
MODE = file
|
||||
LEVEL = trace
|
||||
ROUTER = file
|
||||
|
||||
[log.file]
|
||||
FILE_NAME = forgejo.log
|
||||
|
||||
[security]
|
||||
INSTALL_LOCK = true
|
||||
|
||||
[repository]
|
||||
ENABLE_PUSH_CREATE_USER = true
|
||||
DEFAULT_PUSH_CREATE_PRIVATE = false
|
||||
|
||||
[federation]
|
||||
ENABLED = true
|
33
federation/TWO-app.ini
Normal file
33
federation/TWO-app.ini
Normal file
|
@ -0,0 +1,33 @@
|
|||
RUN_MODE = prod
|
||||
WORK_PATH = forgejo-TWO
|
||||
|
||||
[server]
|
||||
APP_DATA_PATH = ${WORK_PATH}/data
|
||||
DOMAIN = ${IP}
|
||||
HTTP_PORT = 3002
|
||||
SSH_LISTEN_PORT = 2202
|
||||
|
||||
[queue]
|
||||
TYPE = immediate
|
||||
|
||||
[database]
|
||||
DB_TYPE = sqlite3
|
||||
PATH = ${WORK_PATH}/forgejo.db
|
||||
|
||||
[log]
|
||||
MODE = file
|
||||
LEVEL = trace
|
||||
ROUTER = file
|
||||
|
||||
[log.file]
|
||||
FILE_NAME = forgejo.log
|
||||
|
||||
[security]
|
||||
INSTALL_LOCK = true
|
||||
|
||||
[repository]
|
||||
ENABLE_PUSH_CREATE_USER = true
|
||||
DEFAULT_PUSH_CREATE_PRIVATE = false
|
||||
|
||||
[federation]
|
||||
ENABLED = true
|
86
federation/federation.sh
Executable file
86
federation/federation.sh
Executable file
|
@ -0,0 +1,86 @@
|
|||
# Copyright 2024 The Forgejo Authors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
FEDERATION_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
export FEDERATION_INSTANCES="ONE TWO"
|
||||
export FEDERATION_CONFIGS
|
||||
|
||||
function federation_setup_variables() {
|
||||
if test "$FEDERATION_CONFIGS"; then
|
||||
return
|
||||
fi
|
||||
for instance in $FEDERATION_INSTANCES; do
|
||||
local config=$FEDERATION_DIR/$instance-app.ini
|
||||
FEDERATION_CONFIGS="$FEDERATION_CONFIGS $config"
|
||||
local base=$(work_path_base $config)
|
||||
local work_path=$DIR/$base
|
||||
local host_port=$(get_host_port $config)
|
||||
|
||||
eval export ${instance}_CONFIG=$config
|
||||
eval export ${instance}_CURL=$work_path/forgejo-curl.sh
|
||||
eval export ${instance}_HOST_PORT=$host_port
|
||||
done
|
||||
}
|
||||
|
||||
function federation_verify_scenario() {
|
||||
local scenario=$1
|
||||
|
||||
export scenario
|
||||
export SCENARIO_DIR=$FEDERATION_DIR/scenario-$scenario
|
||||
|
||||
if test -f $SCENARIO_DIR/setup.sh; then
|
||||
echo "============================ SETUP scenario-$scenario ==================="
|
||||
bash -ex $SCENARIO_DIR/setup.sh || return 1
|
||||
fi
|
||||
|
||||
echo "============================ RUN scenario-$scenario ==================="
|
||||
bash -ex $SCENARIO_DIR/run.sh || return 1
|
||||
|
||||
if test -f $SCENARIO_DIR/teardown.sh; then
|
||||
echo "============================ TEARDOWN scenario-$scenario ==================="
|
||||
bash -ex $SCENARIO_DIR/teardown.sh || return 1
|
||||
fi
|
||||
}
|
||||
|
||||
function federation_setup() {
|
||||
federation_setup_variables
|
||||
|
||||
local version=$1
|
||||
federation_teardown
|
||||
|
||||
local config
|
||||
for config in $FEDERATION_CONFIGS; do
|
||||
reset_forgejo $config
|
||||
start_forgejo $version $config
|
||||
done
|
||||
}
|
||||
|
||||
function federation_teardown() {
|
||||
federation_setup_variables
|
||||
|
||||
local config
|
||||
for config in $FEDERATION_CONFIGS; do
|
||||
stop_forgejo $config
|
||||
done
|
||||
}
|
||||
|
||||
function test_federation() {
|
||||
# start_gitlab octobus/heptapod:1.5.3
|
||||
federation_setup_variables
|
||||
|
||||
local versions="${1:-$RELEASE_NUMBERS}"
|
||||
|
||||
for version in $versions; do
|
||||
|
||||
if dpkg --compare-versions $version lt 7.1; then
|
||||
continue
|
||||
fi
|
||||
|
||||
federation_setup $version
|
||||
|
||||
for scenario in star; do
|
||||
run federation_verify_scenario $scenario
|
||||
done
|
||||
done
|
||||
}
|
47
federation/scenario-star/run.sh
Normal file
47
federation/scenario-star/run.sh
Normal file
|
@ -0,0 +1,47 @@
|
|||
TMPDIR=$(mktemp -d)
|
||||
|
||||
trap "rm -fr $TMPDIR" EXIT
|
||||
|
||||
source $SCENARIO_DIR/../../lib/lib.sh
|
||||
|
||||
function star_count() {
|
||||
local curl=$1
|
||||
local host_port=$2
|
||||
local count=$3
|
||||
|
||||
$curl api_json http://$host_port/api/v1/repos/root/test >$TMPDIR/count.json
|
||||
if test $count != $(jq -r .stars_count <$TMPDIR/count.json); then
|
||||
jq . <$TMPDIR/count.json
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# create a repo on each instance
|
||||
#
|
||||
$ONE_CURL api_json --data '{"name":"test","auto_init":true}' $ONE_HOST_PORT/api/v1/user/repos >$TMPDIR/one-repo.json
|
||||
one_repo_id=$(jq -r .id <$TMPDIR/one-repo.json)
|
||||
$TWO_CURL api_json --data '{"name":"test","auto_init":true}' $TWO_HOST_PORT/api/v1/user/repos >$TMPDIR/two-repo.json
|
||||
two_repo_id=$(jq -r .id <$TMPDIR/two-repo.json)
|
||||
|
||||
#
|
||||
# the repo in instance two is federated with the repo in instance one
|
||||
#
|
||||
$ONE_CURL web --form action=federation --form following_repos=http://$TWO_HOST_PORT/api/v1/activitypub/repository-id/$two_repo_id http://$ONE_HOST_PORT/root/test/settings
|
||||
|
||||
#
|
||||
# check that both repo have 0 star
|
||||
#
|
||||
star_count $ONE_CURL $ONE_HOST_PORT 0
|
||||
star_count $TWO_CURL $TWO_HOST_PORT 0
|
||||
|
||||
#
|
||||
# star the repo on instance one and expect the star to show on instance two
|
||||
#
|
||||
$ONE_CURL api_json -X PUT $ONE_HOST_PORT/api/v1/user/starred/root/test
|
||||
|
||||
#
|
||||
# check that both repo have 1 star
|
||||
#
|
||||
star_count $ONE_CURL $ONE_HOST_PORT 1
|
||||
retry star_count $TWO_CURL $TWO_HOST_PORT 1
|
1
federation/scenario-star/setup.sh
Normal file
1
federation/scenario-star/setup.sh
Normal file
|
@ -0,0 +1 @@
|
|||
|
1
federation/scenario-star/teardown.sh
Normal file
1
federation/scenario-star/teardown.sh
Normal file
|
@ -0,0 +1 @@
|
|||
|
|
@ -1,30 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
version=$1
|
||||
DIR=$2
|
||||
|
||||
v=$(echo $version | sed -E -e 's/([0-9]+\.[0-9]+).*/\1/')
|
||||
read url ref semver < $SELF_DIR/sources/$v
|
||||
|
||||
rm -fr $DIR/src
|
||||
if [[ "$ref" =~ ^refs/ ]] ; then
|
||||
git clone --depth 1 $url $DIR/src
|
||||
cd $DIR/src
|
||||
git fetch origin +$ref:$ref
|
||||
git checkout -b $v $ref
|
||||
else
|
||||
git clone --depth 1 -b $ref $url $DIR/src
|
||||
cd $DIR/src
|
||||
fi
|
||||
export TAGS="bindata sqlite sqlite_unlock_notify"
|
||||
make deps-backend backend
|
||||
#
|
||||
# use the gitea target here so that branches that do not contain the commit that adds
|
||||
# the `forgejo` target to the Makefile can build successfully
|
||||
#
|
||||
make VERSION=v$version GITEA_VERSION=v$version FORGEJO_VERSION=$semver generate gitea
|
||||
mv gitea $DIR/forgejo-$version
|
6
forgejo/fixtures.sh
Normal file
6
forgejo/fixtures.sh
Normal file
|
@ -0,0 +1,6 @@
|
|||
# SPDX-License-Identifier: MIT
|
||||
|
||||
FIXTURES_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
source $FIXTURES_DIR/fixtures/storage.sh
|
||||
source $FIXTURES_DIR/fixtures/doctor.sh
|
9
forgejo/fixtures/doctor.sh
Normal file
9
forgejo/fixtures/doctor.sh
Normal file
|
@ -0,0 +1,9 @@
|
|||
# SPDX-License-Identifier: MIT
|
||||
|
||||
function doctor_run() {
|
||||
local config=$1
|
||||
local base=$(work_path_base $config)
|
||||
local work_path=$DIR/$base
|
||||
|
||||
$work_path/forgejocli doctor check --all # --log-file -
|
||||
}
|
|
@ -1,4 +1,3 @@
|
|||
#!/bin/bash
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
#ONEPIXEL="iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg=="
|
||||
|
@ -8,20 +7,44 @@
|
|||
#
|
||||
ONEPIXEL="iVBORw0KGgoAAAANSUhEUgAAASIAAAEiCAYAAABdvt+2AAADrElEQVR4nOzUMRHAMADEsL9eeQd6AsOLhMCT/7udAYS+OgDAiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDOiICcEQE5IwJyRgTkjAjIGRGQMyIgZ0RAzoiAnBEBOSMCckYE5IwIyBkRkDMiIGdEQM6IgJwRATkjAnJGBOSMCMgZEZAzIiBnREDuBQAA//+4jAPFe1H1tgAAAABJRU5ErkJggg=="
|
||||
|
||||
STORAGE_FUN="attachments avatars lfs packages repo_archive repo_avatars"
|
||||
: ${FORGEJO_REPO:=fixture}
|
||||
|
||||
function fixture_get_paths_s3() {
|
||||
local path=$1
|
||||
|
||||
(
|
||||
echo -n $path/
|
||||
mc ls --quiet --recursive testS3/$path | sed -e 's/.* //'
|
||||
) > $DIR/path
|
||||
mc ls --quiet --recursive testS3/$path | sed -e "s|.* |$path/|"
|
||||
) >$DIR/path
|
||||
}
|
||||
|
||||
function fixture_content_search_s3() {
|
||||
local path="$1"
|
||||
local expected="$2"
|
||||
|
||||
fixture_get_paths_s3 $path
|
||||
if test $(wc -l <$DIR/path) -lt 1; then
|
||||
echo expected at least one but got "'$(cat $DIR/path)'"
|
||||
return 1
|
||||
fi
|
||||
for filename in $(cat $DIR/path); do
|
||||
local content=$(mc cat testS3/$filename | base64 -w0)
|
||||
if test "$content" = "$expected"; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
echo nothing in $path found with the expected content "$expected"
|
||||
return 1
|
||||
}
|
||||
|
||||
function fixture_get_paths_local() {
|
||||
local path=$1
|
||||
local work_path=$DIR/forgejo-work-path
|
||||
|
||||
( cd $work_path ; find $path -type f) > $DIR/path
|
||||
(
|
||||
cd $work_path
|
||||
find $path -type f
|
||||
) >$DIR/path
|
||||
}
|
||||
|
||||
function fixture_get_one_path() {
|
||||
|
@ -30,7 +53,7 @@ function fixture_get_one_path() {
|
|||
|
||||
fixture_get_paths_$storage $path
|
||||
|
||||
if test $(wc -l < $DIR/path) != 1 ; then
|
||||
if test $(wc -l <$DIR/path) != 1; then
|
||||
echo expected one path but got
|
||||
cat $DIR/path
|
||||
return 1
|
||||
|
@ -57,13 +80,25 @@ function fixture_lfs_create() {
|
|||
(
|
||||
cd $DIR/fixture
|
||||
git lfs track "*.txt"
|
||||
echo CONTENT > file.txt
|
||||
echo CONTENT >file.txt
|
||||
git add .
|
||||
git commit -m 'lfs files'
|
||||
git push
|
||||
)
|
||||
}
|
||||
|
||||
function fixture_lfs_assert() {
|
||||
local d=$(mktemp -d)
|
||||
(
|
||||
git clone http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO} $d/${FORGEJO_REPO}
|
||||
cd $d/${FORGEJO_REPO}
|
||||
rm file.txt
|
||||
git-lfs checkout file.txt
|
||||
test -f file.txt
|
||||
)
|
||||
rm -fr $d
|
||||
}
|
||||
|
||||
function fixture_lfs_assert_s3() {
|
||||
local content=$(mc cat testS3/forgejo/lfs/d6/1e/5fa787e50330288923bd0c9866b44643925965144262288447cf52f9f9b7)
|
||||
test "$content" = CONTENT
|
||||
|
@ -78,9 +113,9 @@ function fixture_lfs_assert_local() {
|
|||
}
|
||||
|
||||
function fixture_packages_create() {
|
||||
echo PACKAGE_CONTENT > $DIR/fixture/package
|
||||
$work_path/forgejo-api -X DELETE http://${HOST_PORT}/api/packages/${FORGEJO_USER}/generic/test_package/1.0.0/file.txt || true
|
||||
$work_path/forgejo-api --upload-file $DIR/fixture/package http://${HOST_PORT}/api/packages/${FORGEJO_USER}/generic/test_package/1.0.0/file.txt
|
||||
echo PACKAGE_CONTENT >$DIR/fixture/package
|
||||
forgejo-curl.sh api_json -X DELETE http://${HOST_PORT}/api/packages/${FORGEJO_USER}/generic/test_package/1.0.0/file.txt || true
|
||||
forgejo-curl.sh api_json --upload-file $DIR/fixture/package http://${HOST_PORT}/api/packages/${FORGEJO_USER}/generic/test_package/1.0.0/file.txt
|
||||
}
|
||||
|
||||
function fixture_packages_assert_s3() {
|
||||
|
@ -96,14 +131,12 @@ function fixture_packages_assert_local() {
|
|||
}
|
||||
|
||||
function fixture_avatars_create() {
|
||||
echo -n $ONEPIXEL | base64 --decode > $DIR/avatar.png
|
||||
$work_path/forgejo-client --form avatar=@$DIR/avatar.png http://${HOST_PORT}/user/settings/avatar
|
||||
echo -n $ONEPIXEL | base64 --decode >$DIR/avatar.png
|
||||
forgejo-curl.sh web --form avatar=@$DIR/avatar.png http://${HOST_PORT}/user/settings/avatar
|
||||
}
|
||||
|
||||
function fixture_avatars_assert_s3() {
|
||||
local filename=$(fixture_get_one_path s3 forgejo/avatars)
|
||||
local content=$(mc cat testS3/$filename | base64 -w0)
|
||||
test "$content" = "$ONEPIXEL"
|
||||
fixture_content_search_s3 forgejo/avatars "$ONEPIXEL"
|
||||
}
|
||||
|
||||
function fixture_avatars_assert_local() {
|
||||
|
@ -115,10 +148,8 @@ function fixture_avatars_assert_local() {
|
|||
}
|
||||
|
||||
function fixture_repo_avatars_create() {
|
||||
echo -n $ONEPIXEL | base64 --decode > $DIR/repo-avatar.png
|
||||
$work_path/forgejo-client --form avatar=@$DIR/repo-avatar.png http://${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}/settings/avatar
|
||||
# v1.21 only
|
||||
#$work_path/forgejo-api -X POST --data-raw '{"body":"'$avatar'"}' http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/avatar
|
||||
echo -n $ONEPIXEL | base64 --decode >$DIR/repo-avatar.png
|
||||
forgejo-curl.sh web --form avatar=@$DIR/repo-avatar.png http://${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}/settings/avatar
|
||||
}
|
||||
|
||||
function fixture_repo_avatars_assert_s3() {
|
||||
|
@ -136,18 +167,18 @@ function fixture_repo_avatars_assert_local() {
|
|||
}
|
||||
|
||||
function fixture_attachments_create_1_18() {
|
||||
echo -n $ONEPIXEL | base64 --decode > $DIR/attachment.png
|
||||
$work_path/forgejo-client --trace-ascii - --form file=@$DIR/attachment.png http://${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}/issues/attachments
|
||||
echo -n $ONEPIXEL | base64 --decode >$DIR/attachment.png
|
||||
forgejo-curl.sh web --trace-ascii - --form file=@$DIR/attachment.png http://${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}/issues/attachments
|
||||
}
|
||||
|
||||
function fixture_attachments_create() {
|
||||
if $work_path/forgejo-api http://${HOST_PORT}/api/v1/version | grep --quiet --fixed-strings 1.18. ; then
|
||||
if forgejo-curl.sh api_json http://${HOST_PORT}/api/v1/version | grep --quiet --fixed-strings 1.18.; then
|
||||
fixture_attachments_create_1_18
|
||||
return
|
||||
fi
|
||||
id=$($work_path/forgejo-api --data-raw '{"title":"TITLE"}' http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/issues | jq .id)
|
||||
echo -n $ONEPIXEL | base64 --decode > $DIR/attachment.png
|
||||
$work_path/forgejo-client -H @$DIR/forgejo-work-path/forgejo-header --form name=attachment.png --form attachment=@$DIR/attachment.png http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/issues/$id/assets
|
||||
id=$(forgejo-curl.sh api_json --data-raw '{"title":"TITLE"}' http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/issues | jq .id)
|
||||
echo -n $ONEPIXEL | base64 --decode >$DIR/attachment.png
|
||||
forgejo-curl.sh api --form name=attachment.png --form attachment=@$DIR/attachment.png http://${HOST_PORT}/api/v1/repos/${FORGEJO_USER}/${FORGEJO_REPO}/issues/$id/assets
|
||||
}
|
||||
|
||||
function fixture_attachments_assert_s3() {
|
||||
|
@ -176,12 +207,18 @@ function fixture_create() {
|
|||
git remote add origin http://${FORGEJO_USER}:${FORGEJO_PASSWORD}@${HOST_PORT}/${FORGEJO_USER}/${FORGEJO_REPO}
|
||||
git config user.email root@example.com
|
||||
git config user.name username
|
||||
echo SOMETHING > README
|
||||
echo SOMETHING >README
|
||||
git add README
|
||||
git commit -m 'initial commit'
|
||||
git push --set-upstream --force origin main
|
||||
)
|
||||
for fun in ${STORAGE_FUN} ; do
|
||||
for fun in ${STORAGE_FUN}; do
|
||||
fixture_${fun}_create
|
||||
done
|
||||
}
|
||||
|
||||
function fixture_assert() {
|
||||
for fun in lfs; do
|
||||
fixture_${fun}_assert
|
||||
done
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
https://codeberg.org/forgejo/forgejo v1.20/forgejo 5.0.0+0-gitea-1.20.0
|
|
@ -1 +0,0 @@
|
|||
https://codeberg.org/forgejo/forgejo v1.21/forgejo 6.0.0+0-gitea-1.21.0
|
|
@ -1 +0,0 @@
|
|||
https://codeberg.org/forgejo/forgejo forgejo 7.0.0+0-gitea-1.22.0
|
1
forgejo/sources/10.0
Normal file
1
forgejo/sources/10.0
Normal file
|
@ -0,0 +1 @@
|
|||
https://codeberg.org/forgejo/forgejo forgejo 10.0.0+gitea-1.22
|
1
forgejo/sources/11.0
Normal file
1
forgejo/sources/11.0
Normal file
|
@ -0,0 +1 @@
|
|||
https://codeberg.org/forgejo/forgejo forgejo 11.0.0
|
1
forgejo/sources/7.0
Normal file
1
forgejo/sources/7.0
Normal file
|
@ -0,0 +1 @@
|
|||
https://codeberg.org/forgejo/forgejo v7.0/forgejo 7.0.0+gitea-1.21.0
|
1
forgejo/sources/8.0
Normal file
1
forgejo/sources/8.0
Normal file
|
@ -0,0 +1 @@
|
|||
https://codeberg.org/forgejo/forgejo v8.0/forgejo 8.0.0+gitea-1.22.0
|
1
forgejo/sources/9.0
Normal file
1
forgejo/sources/9.0
Normal file
|
@ -0,0 +1 @@
|
|||
https://codeberg.org/forgejo/forgejo forgejo 9.0.0+gitea-1.22.0
|
|
@ -1,59 +0,0 @@
|
|||
RUN_MODE = prod
|
||||
WORK_PATH = ${WORK_PATH}
|
||||
|
||||
[server]
|
||||
APP_DATA_PATH = ${WORK_PATH}/elsewhere
|
||||
HTTP_PORT = 3000
|
||||
SSH_LISTEN_PORT = 2222
|
||||
LFS_START_SERVER = true
|
||||
|
||||
[database]
|
||||
DB_TYPE = sqlite3
|
||||
|
||||
[log]
|
||||
MODE = file
|
||||
LEVEL = debug
|
||||
ROUTER = file
|
||||
|
||||
[log.file]
|
||||
FILE_NAME = forgejo.log
|
||||
|
||||
[security]
|
||||
INSTALL_LOCK = true
|
||||
|
||||
[repository]
|
||||
ENABLE_PUSH_CREATE_USER = true
|
||||
DEFAULT_PUSH_CREATE_PRIVATE = false
|
||||
|
||||
[actions]
|
||||
ENABLED = true
|
||||
|
||||
[attachment]
|
||||
|
||||
[storage.attachments]
|
||||
PATH = ${WORK_PATH}/data/attachments
|
||||
|
||||
[lfs]
|
||||
|
||||
[storage.lfs]
|
||||
PATH = ${WORK_PATH}/data/lfs
|
||||
|
||||
[avatar]
|
||||
|
||||
[storage.avatars]
|
||||
PATH = ${WORK_PATH}/data/avatars
|
||||
|
||||
[repo-avatar]
|
||||
|
||||
[storage.repo-avatars]
|
||||
PATH = ${WORK_PATH}/data/repo-avatars
|
||||
|
||||
[repo-archive]
|
||||
|
||||
[storage.repo-archive]
|
||||
PATH = ${WORK_PATH}/data/repo-archive
|
||||
|
||||
[packages]
|
||||
|
||||
[storage.packages]
|
||||
PATH = ${WORK_PATH}/data/packages
|
|
@ -1,89 +0,0 @@
|
|||
RUN_MODE = prod
|
||||
WORK_PATH = ${WORK_PATH}
|
||||
|
||||
[server]
|
||||
APP_DATA_PATH = ${WORK_PATH}/elsewhere
|
||||
HTTP_PORT = 3000
|
||||
SSH_LISTEN_PORT = 2222
|
||||
LFS_START_SERVER = true
|
||||
|
||||
[database]
|
||||
DB_TYPE = sqlite3
|
||||
|
||||
[log]
|
||||
MODE = file
|
||||
LEVEL = debug
|
||||
ROUTER = file
|
||||
|
||||
[log.file]
|
||||
FILE_NAME = forgejo.log
|
||||
|
||||
[security]
|
||||
INSTALL_LOCK = true
|
||||
|
||||
[repository]
|
||||
ENABLE_PUSH_CREATE_USER = true
|
||||
DEFAULT_PUSH_CREATE_PRIVATE = false
|
||||
|
||||
[actions]
|
||||
ENABLED = true
|
||||
|
||||
[attachment]
|
||||
STORAGE_TYPE = minio
|
||||
SERVE_DIRECT = false
|
||||
MINIO_ENDPOINT = 127.0.0.1:9000
|
||||
MINIO_ACCESS_KEY_ID = 123456
|
||||
MINIO_SECRET_ACCESS_KEY = 12345678
|
||||
MINIO_BUCKET = forgejo
|
||||
MINIO_LOCATION = us-east-1
|
||||
MINIO_USE_SSL = false
|
||||
|
||||
[lfs]
|
||||
STORAGE_TYPE = minio
|
||||
SERVE_DIRECT = false
|
||||
MINIO_ENDPOINT = 127.0.0.1:9000
|
||||
MINIO_ACCESS_KEY_ID = 123456
|
||||
MINIO_SECRET_ACCESS_KEY = 12345678
|
||||
MINIO_BUCKET = forgejo
|
||||
MINIO_LOCATION = us-east-1
|
||||
MINIO_USE_SSL = false
|
||||
|
||||
[repo-avatar]
|
||||
STORAGE_TYPE = minio
|
||||
SERVE_DIRECT = false
|
||||
MINIO_ENDPOINT = 127.0.0.1:9000
|
||||
MINIO_ACCESS_KEY_ID = 123456
|
||||
MINIO_SECRET_ACCESS_KEY = 12345678
|
||||
MINIO_BUCKET = forgejo
|
||||
MINIO_LOCATION = us-east-1
|
||||
MINIO_USE_SSL = false
|
||||
|
||||
[avatar]
|
||||
STORAGE_TYPE = minio
|
||||
SERVE_DIRECT = false
|
||||
MINIO_ENDPOINT = 127.0.0.1:9000
|
||||
MINIO_ACCESS_KEY_ID = 123456
|
||||
MINIO_SECRET_ACCESS_KEY = 12345678
|
||||
MINIO_BUCKET = forgejo
|
||||
MINIO_LOCATION = us-east-1
|
||||
MINIO_USE_SSL = false
|
||||
|
||||
[repo-archive]
|
||||
STORAGE_TYPE = minio
|
||||
SERVE_DIRECT = false
|
||||
MINIO_ENDPOINT = 127.0.0.1:9000
|
||||
MINIO_ACCESS_KEY_ID = 123456
|
||||
MINIO_SECRET_ACCESS_KEY = 12345678
|
||||
MINIO_BUCKET = forgejo
|
||||
MINIO_LOCATION = us-east-1
|
||||
MINIO_USE_SSL = false
|
||||
|
||||
[packages]
|
||||
STORAGE_TYPE = minio
|
||||
SERVE_DIRECT = false
|
||||
MINIO_ENDPOINT = 127.0.0.1:9000
|
||||
MINIO_ACCESS_KEY_ID = 123456
|
||||
MINIO_SECRET_ACCESS_KEY = 12345678
|
||||
MINIO_BUCKET = forgejo
|
||||
MINIO_LOCATION = us-east-1
|
||||
MINIO_USE_SSL = false
|
|
@ -1,113 +0,0 @@
|
|||
RUN_MODE = prod
|
||||
WORK_PATH = ${WORK_PATH}
|
||||
|
||||
[server]
|
||||
APP_DATA_PATH = ${WORK_PATH}/elsewhere
|
||||
HTTP_PORT = 3000
|
||||
SSH_LISTEN_PORT = 2222
|
||||
LFS_START_SERVER = true
|
||||
|
||||
[database]
|
||||
DB_TYPE = sqlite3
|
||||
|
||||
[log]
|
||||
MODE = file
|
||||
LEVEL = debug
|
||||
ROUTER = file
|
||||
|
||||
[log.file]
|
||||
FILE_NAME = forgejo.log
|
||||
|
||||
[security]
|
||||
INSTALL_LOCK = true
|
||||
|
||||
[repository]
|
||||
ENABLE_PUSH_CREATE_USER = true
|
||||
DEFAULT_PUSH_CREATE_PRIVATE = false
|
||||
|
||||
[actions]
|
||||
ENABLED = true
|
||||
|
||||
[storage.attachments]
|
||||
STORAGE_TYPE = minio
|
||||
SERVE_DIRECT = false
|
||||
MINIO_ENDPOINT = 127.0.0.1:9000
|
||||
MINIO_ACCESS_KEY_ID = 123456
|
||||
MINIO_SECRET_ACCESS_KEY = 12345678
|
||||
MINIO_BUCKET = forgejo
|
||||
MINIO_LOCATION = us-east-1
|
||||
MINIO_USE_SSL = false
|
||||
|
||||
[storage.lfs]
|
||||
STORAGE_TYPE = minio
|
||||
SERVE_DIRECT = false
|
||||
MINIO_ENDPOINT = 127.0.0.1:9000
|
||||
MINIO_ACCESS_KEY_ID = 123456
|
||||
MINIO_SECRET_ACCESS_KEY = 12345678
|
||||
MINIO_BUCKET = forgejo
|
||||
MINIO_LOCATION = us-east-1
|
||||
MINIO_USE_SSL = false
|
||||
|
||||
[picture]
|
||||
AVATAR_STORAGE_TYPE = minio
|
||||
REPOSITORY_AVATAR_STORAGE_TYPE = minio
|
||||
|
||||
[storage.repo-avatars]
|
||||
STORAGE_TYPE = minio
|
||||
SERVE_DIRECT = false
|
||||
MINIO_ENDPOINT = 127.0.0.1:9000
|
||||
MINIO_ACCESS_KEY_ID = 123456
|
||||
MINIO_SECRET_ACCESS_KEY = 12345678
|
||||
MINIO_BUCKET = forgejo
|
||||
MINIO_LOCATION = us-east-1
|
||||
MINIO_USE_SSL = false
|
||||
|
||||
[storage.minio]
|
||||
STORAGE_TYPE = minio
|
||||
SERVE_DIRECT = false
|
||||
MINIO_ENDPOINT = 127.0.0.1:9000
|
||||
MINIO_ACCESS_KEY_ID = 123456
|
||||
MINIO_SECRET_ACCESS_KEY = 12345678
|
||||
MINIO_BUCKET = forgejo
|
||||
MINIO_LOCATION = us-east-1
|
||||
MINIO_USE_SSL = false
|
||||
|
||||
[storage]
|
||||
STORAGE_TYPE = minio
|
||||
SERVE_DIRECT = false
|
||||
MINIO_ENDPOINT = 127.0.0.1:9000
|
||||
MINIO_ACCESS_KEY_ID = 123456
|
||||
MINIO_SECRET_ACCESS_KEY = 12345678
|
||||
MINIO_BUCKET = forgejo
|
||||
MINIO_LOCATION = us-east-1
|
||||
MINIO_USE_SSL = false
|
||||
|
||||
[storage.avatars]
|
||||
STORAGE_TYPE = minio
|
||||
SERVE_DIRECT = false
|
||||
MINIO_ENDPOINT = 127.0.0.1:9000
|
||||
MINIO_ACCESS_KEY_ID = 123456
|
||||
MINIO_SECRET_ACCESS_KEY = 12345678
|
||||
MINIO_BUCKET = forgejo
|
||||
MINIO_LOCATION = us-east-1
|
||||
MINIO_USE_SSL = false
|
||||
|
||||
[storage.repo-archive]
|
||||
STORAGE_TYPE = minio
|
||||
SERVE_DIRECT = false
|
||||
MINIO_ENDPOINT = 127.0.0.1:9000
|
||||
MINIO_ACCESS_KEY_ID = 123456
|
||||
MINIO_SECRET_ACCESS_KEY = 12345678
|
||||
MINIO_BUCKET = forgejo
|
||||
MINIO_LOCATION = us-east-1
|
||||
MINIO_USE_SSL = false
|
||||
|
||||
[storage.packages]
|
||||
STORAGE_TYPE = minio
|
||||
SERVE_DIRECT = false
|
||||
MINIO_ENDPOINT = 127.0.0.1:9000
|
||||
MINIO_ACCESS_KEY_ID = 123456
|
||||
MINIO_SECRET_ACCESS_KEY = 12345678
|
||||
MINIO_BUCKET = forgejo
|
||||
MINIO_LOCATION = us-east-1
|
||||
MINIO_USE_SSL = false
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue