mirror of
https://code.forgejo.org/actions/setup-forgejo.git
synced 2024-11-23 22:40:58 -05:00
Merge pull request 'fix transient errors in tests' (#54) from earl-warren/setup-forgejo:wip-artifacts into main
Reviewed-on: https://code.forgejo.org/actions/setup-forgejo/pulls/54 Reviewed-by: dachary <dachary@noreply.code.forgejo.org>
This commit is contained in:
commit
15a24e808e
9 changed files with 100 additions and 133 deletions
|
@ -1,28 +0,0 @@
|
|||
on:
|
||||
push:
|
||||
paths:
|
||||
- forgejo.sh
|
||||
- .forgejo/workflows/forgejo-sh.yml
|
||||
pull_request:
|
||||
paths:
|
||||
- forgejo.sh
|
||||
- .forgejo/workflows/forgejo-sh.yml
|
||||
|
||||
jobs:
|
||||
forgejo-sh:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- run: |
|
||||
set -x
|
||||
export PATH=$(pwd):$PATH
|
||||
forgejo-dependencies.sh install_docker
|
||||
(
|
||||
echo codeberg.org/forgejo/forgejo 1.19.4-0
|
||||
echo codeberg.org/forgejo/forgejo 1.20.4-1
|
||||
echo codeberg.org/forgejo-experimental/forgejo 1.21.0-2-rc0
|
||||
) | while read url version ; do
|
||||
echo "=========================== launching forgejo v$version =========="
|
||||
forgejo.sh setup root admin1234 $url $version
|
||||
forgejo.sh teardown
|
||||
done
|
|
@ -1,24 +0,0 @@
|
|||
on: [ push, pull_request ]
|
||||
jobs:
|
||||
integration-nested:
|
||||
runs-on: self-hosted
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- run: |
|
||||
set -x
|
||||
LXC_IP_PREFIX=10.0.9 ./forgejo-dependencies.sh
|
||||
export PATH=$(pwd):$PATH
|
||||
forgejo.sh setup root admin1234 codeberg.org/forgejo/forgejo 1.20
|
||||
#
|
||||
# Uncomment the following for a shortcut to debugging the Forgejo runner.
|
||||
# It will build the runner from a designated repository and branch instead of
|
||||
# downloading it from a canonical release.
|
||||
#
|
||||
# ./forgejo-test-helper.sh build_runner http://code.forgejo.org/forgejo/runner branch-under-debug
|
||||
# export PATH=$(pwd)/forgejo-runner:$PATH
|
||||
#
|
||||
./forgejo-runner.sh setup
|
||||
export FORGEJO_RUNNER_LOGS=forgejo-runner.log
|
||||
echo "============================ sanity-check ==================="
|
||||
./forgejo-test-helper.sh push_self_action http://root:admin1234@$(cat forgejo-ip):3000 root setup-forgejo vTest
|
||||
./forgejo-test-helper.sh run_workflow testdata/sanity-checks http://root:admin1234@$(cat forgejo-ip):3000 root sanity-check setup-forgejo $(cat forgejo-token)
|
|
@ -8,24 +8,16 @@ jobs:
|
|||
info:
|
||||
- version: "1.21.0-2-rc0"
|
||||
image: codeberg.org/forgejo-experimental/forgejo
|
||||
tests: "service"
|
||||
- version: "1.21.0-2-rc0"
|
||||
image: codeberg.org/forgejo-experimental/forgejo
|
||||
tests: "artifacts"
|
||||
- version: "1.21.0-2-rc0"
|
||||
image: codeberg.org/forgejo-experimental/forgejo
|
||||
tests: "cron"
|
||||
- version: "1.21.0-2-rc0"
|
||||
image: codeberg.org/forgejo-experimental/forgejo
|
||||
tests: "${{ vars.V121_TESTS || 'echo checkout pull-request container expression local-action docker-action if if-fail' }}"
|
||||
# keep "cron" last otherwise it will linger and pollute the following runs
|
||||
tests: "${{ vars.V120_TESTS || 'echo artifacts service checkout pull-request container expression local-action docker-action if if-fail cron' }}"
|
||||
- version: "1.20"
|
||||
image: codeberg.org/forgejo/forgejo
|
||||
tests: "${{ vars.V120_TESTS || 'echo checkout service container expression local-action docker-action if if-fail' }}"
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- if: matrix.info.tests != 'none'
|
||||
shell: bash
|
||||
run: |
|
||||
set -x
|
||||
LXC_IP_PREFIX=10.0.10 ./forgejo-dependencies.sh
|
||||
export PATH=$(pwd):$PATH
|
||||
forgejo.sh setup root admin1234 ${{ matrix.info.image }} ${{ matrix.info.version }}
|
||||
|
@ -40,29 +32,41 @@ jobs:
|
|||
forgejo-runner.sh setup
|
||||
export FORGEJO_RUNNER_LOGS=forgejo-runner.log
|
||||
|
||||
for example in ${{ matrix.info.tests }} ; do
|
||||
echo "============================ demo ==================="
|
||||
./forgejo-test-helper.sh run_workflow testdata/demo http://root:admin1234@$(cat forgejo-ip):3000 root demo setup-forgejo $(cat forgejo-token) > /tmp/output
|
||||
grep '^sha=' /tmp/output
|
||||
|
||||
function run() {
|
||||
local example=$1
|
||||
|
||||
export example
|
||||
export EXAMPLE_DIR=$(pwd)/testdata/example-$example
|
||||
|
||||
if test -f $EXAMPLE_DIR/setup.sh ; then
|
||||
$EXAMPLE_DIR/setup.sh
|
||||
echo "============================ SETUP example-$example ==================="
|
||||
bash -ex $EXAMPLE_DIR/setup.sh || return 1
|
||||
fi
|
||||
|
||||
echo "============================ BEGIN example-$example ==================="
|
||||
if test -f $EXAMPLE_DIR/run.sh ; then
|
||||
$EXAMPLE_DIR/run.sh
|
||||
echo "============================ RUN example-$example ==================="
|
||||
bash -ex $EXAMPLE_DIR/run.sh || return 1
|
||||
else
|
||||
if ! forgejo-test-helper.sh run_workflow testdata/example-$example http://root:admin1234@$(cat forgejo-ip):3000 root example-$example setup-forgejo $(cat forgejo-token) >& /tmp/run.out ; then
|
||||
cat /tmp/run.out
|
||||
false
|
||||
forgejo-test-helper.sh run_workflow testdata/example-$example http://root:admin1234@$(cat forgejo-ip):3000 root example-$example setup-forgejo $(cat forgejo-token) || return 1
|
||||
fi
|
||||
fi
|
||||
echo "============================ END example-$example ==================="
|
||||
|
||||
if test -f $EXAMPLE_DIR/teardown.sh ; then
|
||||
$EXAMPLE_DIR/teardown.sh
|
||||
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
|
||||
echo "============================ demo ==================="
|
||||
./forgejo-test-helper.sh run_workflow testdata/demo http://root:admin1234@$(cat forgejo-ip):3000 root demo setup-forgejo $(cat forgejo-token) > /tmp/output
|
||||
grep '^sha=' /tmp/output
|
||||
|
|
|
@ -32,13 +32,17 @@ function register() {
|
|||
|
||||
function run() {
|
||||
rm -f forgejo-runner.log
|
||||
daemon --chdir=$(pwd) --unsafe --env="TERM=$TERM" --env="HOME=$HOME" --env="PATH=$PATH" --env="USER=$USER" --env="TERM=dumb" --env="USERNAME=$USERNAME" --env="LANG=$LANG" --pidfile=$(pwd)/forgejo-runner-pid --errlog=$(pwd)/forgejo-runner.log --output=$(pwd)/forgejo-runner.log -- forgejo-runner --config $FORGEJO_RUNNER_CONFIG daemon
|
||||
daemon --chdir=$(pwd) --unsafe \
|
||||
--env="TERM=$TERM" --env="HOME=$HOME" --env="PATH=$PATH" --env="USER=$USER" --env="TERM=dumb" --env="USERNAME=$USERNAME" --env="LANG=$LANG" \
|
||||
--pidfile=$(pwd)/forgejo-runner-pid --errlog=$(pwd)/forgejo-runner.log --output=$(pwd)/forgejo-runner.log -- \
|
||||
forgejo-runner --config $FORGEJO_RUNNER_CONFIG daemon
|
||||
sleep 1
|
||||
cat forgejo-runner.log
|
||||
}
|
||||
|
||||
function reload() {
|
||||
teardown
|
||||
rm -f forgejo-runner.log
|
||||
run
|
||||
}
|
||||
|
||||
|
@ -53,11 +57,26 @@ function setup() {
|
|||
run
|
||||
}
|
||||
|
||||
function teardown() {
|
||||
if test -f forgejo-runner-pid ; then
|
||||
kill -TERM $(cat forgejo-runner-pid)
|
||||
rm -f forgejo-runner-pid
|
||||
function stop_daemon() {
|
||||
local daemon=$1
|
||||
local DIR=.
|
||||
|
||||
if test -f $DIR/$daemon-pid ; then
|
||||
local pid=$(cat $DIR/$daemon-pid)
|
||||
kill -TERM $pid
|
||||
pidwait $pid || true
|
||||
for delay in 1 1 2 2 5 5 ; do
|
||||
if ! test -f $DIR/$daemon-pid ; then
|
||||
break
|
||||
fi
|
||||
sleep $delay
|
||||
done
|
||||
! test -f $DIR/$daemon-pid
|
||||
fi
|
||||
}
|
||||
|
||||
function teardown() {
|
||||
stop_daemon forgejo-runner
|
||||
}
|
||||
|
||||
"$@"
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
on: [push]
|
||||
jobs:
|
||||
upload:
|
||||
runs-on: docker
|
||||
steps:
|
||||
- run: mkdir -p artifacts
|
||||
|
||||
- run: touch artifacts/ONE artifacts/TWO
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: many-artifacts
|
||||
path: artifacts/
|
||||
|
||||
download:
|
||||
runs-on: docker
|
||||
steps:
|
||||
- uses: actions/download-artifact@v3
|
||||
|
||||
- run: |
|
||||
test -f many-artifacts/ONE
|
||||
test -f many-artifacts/TWO
|
|
@ -1,24 +0,0 @@
|
|||
on: [push]
|
||||
jobs:
|
||||
upload:
|
||||
runs-on: docker
|
||||
steps:
|
||||
- run: mkdir -p path/to/artifact
|
||||
|
||||
- run: echo hello > path/to/artifact/world.txt
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: my-artifact
|
||||
path: path/to/artifact/world.txt
|
||||
|
||||
download:
|
||||
runs-on: docker
|
||||
steps:
|
||||
- run: "! test -f world.txt"
|
||||
|
||||
- uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: my-artifact
|
||||
|
||||
- run: "test -f world.txt"
|
47
testdata/example-artifacts/.forgejo/workflows/test.yml
vendored
Normal file
47
testdata/example-artifacts/.forgejo/workflows/test.yml
vendored
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: actions/upload-artifact@v3
|
||||
with:
|
||||
name: many-artifacts
|
||||
path: artifacts/
|
||||
|
||||
download-many:
|
||||
needs: [upload-many]
|
||||
runs-on: docker
|
||||
steps:
|
||||
- uses: actions/download-artifact@v3
|
||||
|
||||
- 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: actions/upload-artifact@v3
|
||||
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: actions/download-artifact@v3
|
||||
with:
|
||||
name: my-artifact
|
||||
|
||||
- run: "test -f world.txt"
|
5
testdata/example-if-fail/run.sh
vendored
5
testdata/example-if-fail/run.sh
vendored
|
@ -1,7 +1,4 @@
|
|||
if forgejo-test-helper.sh run_workflow testdata/example-$example http://root:admin1234@$(cat forgejo-ip):3000 root example-$example setup-forgejo $(cat forgejo-token) >& /tmp/run.out ; then
|
||||
cat /tmp/run.out
|
||||
false
|
||||
fi
|
||||
! forgejo-test-helper.sh run_workflow testdata/example-$example http://root:admin1234@$(cat forgejo-ip):3000 root example-$example setup-forgejo $(cat forgejo-token)
|
||||
|
||||
grep --quiet 'IF TEST FAILURE' $FORGEJO_RUNNER_LOGS
|
||||
grep --quiet 'IF TEST ALWAYS' $FORGEJO_RUNNER_LOGS
|
||||
|
|
2
testdata/example-pull-request/run.sh
vendored
2
testdata/example-pull-request/run.sh
vendored
|
@ -1,5 +1,3 @@
|
|||
set -e
|
||||
|
||||
url=http://root:admin1234@$(cat forgejo-ip):3000
|
||||
api=$url/api/v1
|
||||
export d=/srv/example-pull-request
|
||||
|
|
Loading…
Reference in a new issue