Merge pull request 'actions: rework to use binaries instead of docker images' (#41) from earl-warren/end-to-end:wip-binary into main
Reviewed-on: https://code.forgejo.org/forgejo/end-to-end/pulls/41 Reviewed-by: dachary <dachary@noreply.code.forgejo.org>
This commit is contained in:
commit
2b980ab4ca
5 changed files with 138 additions and 61 deletions
|
@ -10,60 +10,31 @@ jobs:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
info:
|
info:
|
||||||
- version: "1.21"
|
- binary: https://codeberg.org/forgejo-experimental/forgejo/releases/download/v1.22.0-test/forgejo-1.22.0-test-linux-amd64
|
||||||
image: codeberg.org/forgejo/forgejo
|
version: v1_22
|
||||||
# keep "cron" last otherwise it will linger and pollute the following runs
|
tests: ${{ vars.V1_22_TESTS }}
|
||||||
tests: "${{ vars.V1_21_TESTS || 'echo push-cancel artifacts service checkout pull-request container expression local-action docker-action if if-fail cron' }}"
|
- binary: https://codeberg.org/forgejo/forgejo/releases/download/v1.21.2-1/forgejo-1.21.2-1-linux-amd64
|
||||||
- version: "1.20"
|
version: v1_21
|
||||||
image: codeberg.org/forgejo/forgejo
|
tests: ${{ vars.V1_21_TESTS }}
|
||||||
tests: "${{ vars.V1_20_TESTS || 'echo checkout service container expression local-action docker-action if if-fail' }}"
|
- 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:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
- uses: https://code.forgejo.org/actions/setup-forgejo@v1
|
- uses: https://code.forgejo.org/actions/setup-forgejo@v2
|
||||||
with:
|
with:
|
||||||
install-only: true
|
install-only: true
|
||||||
|
|
||||||
- if: matrix.info.tests != 'none'
|
- if: matrix.info.tests != 'none'
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
forgejo.sh setup root admin1234 ${{ matrix.info.image }} ${{ matrix.info.version }}
|
set -x
|
||||||
forgejo-runner.sh setup
|
forgejo-binary.sh ensure_user forgejo
|
||||||
export FORGEJO_RUNNER_LOGS=forgejo-runner.log
|
test "${{ matrix.info.binary }}"
|
||||||
export url=http://root:admin1234@$(cat forgejo-ip):3000
|
test "${{ matrix.info.version }}"
|
||||||
export token=$(cat forgejo-token)
|
|
||||||
|
|
||||||
function run() {
|
export DIR=$(mktemp -d)
|
||||||
local example=$1
|
chown forgejo $DIR /srv
|
||||||
|
|
||||||
export example
|
su -c "actions/run.sh ${{ matrix.info.binary }} ${{ matrix.info.version }} ${{ matrix.info.tests }}" forgejo
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
for example in ${{ matrix.info.tests }} ; 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 but by which the last lines of the output are moved to the next step
|
|
||||||
false
|
|
||||||
fi
|
|
||||||
echo "============================ END example-$example ==================="
|
|
||||||
done
|
|
||||||
|
|
31
README.md
31
README.md
|
@ -27,23 +27,25 @@ git clone https://code.forgejo.org/actions/setup-forgejo
|
||||||
export PATH=$(pwd)/setup-forgejo:$PATH
|
export PATH=$(pwd)/setup-forgejo:$PATH
|
||||||
git clone https://code.forgejo.org/forgejo/end-to-end
|
git clone https://code.forgejo.org/forgejo/end-to-end
|
||||||
cd end-to-end
|
cd end-to-end
|
||||||
forgejo-curl.sh logout
|
export DIR=/tmp/end-to-end
|
||||||
forgejo-runner.sh teardown
|
|
||||||
forgejo.sh teardown
|
|
||||||
forgejo.sh setup root admin1234 codeberg.org/forgejo/forgejo 1.21
|
|
||||||
forgejo-runner.sh setup
|
|
||||||
export url=http://root:admin1234@$(cat forgejo-ip):3000
|
|
||||||
export token=$(cat forgejo-token)
|
|
||||||
```
|
```
|
||||||
### Run a single test
|
|
||||||
|
Run one example
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
export example=pull-request
|
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
|
||||||
export EXAMPLE_DIR=$(pwd)/actions/example-$example
|
```
|
||||||
sudo rm -fr /srv/example-$example ; mkdir /srv/example-$example
|
|
||||||
$EXAMPLE_DIR/setup.sh
|
Cleanup
|
||||||
$EXAMPLE_DIR/run.sh
|
|
||||||
forgejo-test-helper.sh run_workflow actions/example-$example http://root:admin1234@$(cat forgejo-ip):3000 root example-$example setup-forgejo $(cat forgejo-token)
|
```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
|
||||||
|
```
|
||||||
|
|
||||||
|
Run all examples for v1_22
|
||||||
|
|
||||||
|
```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
|
||||||
```
|
```
|
||||||
|
|
||||||
### Remote testing
|
### Remote testing
|
||||||
|
@ -54,5 +56,6 @@ the number of cases run by the
|
||||||
**none** they are not run at all for that version of Forgejo. If
|
**none** they are not run at all for that version of Forgejo. If
|
||||||
it does not exist, all tests are run.
|
it does not exist, all tests are run.
|
||||||
|
|
||||||
|
* `V1_22_TESTS`
|
||||||
* `V1_21_TESTS`
|
* `V1_21_TESTS`
|
||||||
* `V1_20_TESTS`
|
* `V1_20_TESTS`
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
mkdir /srv/example-cron-volume
|
rm -fr /srv/example-cron-volume
|
||||||
|
mkdir -p /srv/example-cron-volume
|
||||||
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload
|
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload
|
||||||
|
|
|
@ -1,2 +1,8 @@
|
||||||
|
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
|
mkdir -p /srv/example-pull-request
|
||||||
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload
|
FORGEJO_RUNNER_CONFIG=$EXAMPLE_DIR/runner-config.yaml forgejo-runner.sh reload
|
||||||
|
|
96
actions/run.sh
Executable file
96
actions/run.sh
Executable file
|
@ -0,0 +1,96 @@
|
||||||
|
#!/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 "$@"
|
Loading…
Add table
Reference in a new issue