mirror of
https://code.forgejo.org/actions/setup-forgejo.git
synced 2024-11-27 08:40:57 -05:00
automatically build from source if the version is @branch
This commit is contained in:
parent
0e868f6735
commit
40950130a5
10 changed files with 83 additions and 70 deletions
|
@ -9,16 +9,8 @@ jobs:
|
|||
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
|
||||
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)
|
||||
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)
|
||||
|
|
|
@ -21,14 +21,6 @@ jobs:
|
|||
LXC_IP_PREFIX=10.0.10 ./forgejo-dependencies.sh
|
||||
export PATH=$(pwd):$PATH
|
||||
forgejo.sh setup root admin1234 ${{ matrix.info.image }} ${{ matrix.info.version }}
|
||||
#
|
||||
# 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/earl-warren/runner wip-sync
|
||||
#export PATH=$(pwd)/forgejo-runner:$PATH
|
||||
#
|
||||
forgejo-runner.sh setup
|
||||
export FORGEJO_RUNNER_LOGS=forgejo-runner.log
|
||||
url=http://root:admin1234@$(cat forgejo-ip):3000
|
||||
|
|
|
@ -21,11 +21,6 @@ The forgejo-test-helper.sh script is available to help test and debug actions.
|
|||
* `forgejo-test-helper.sh push testrepo $forgejo root testrepo`
|
||||
Creates the repository `$forgejo/root/testrepo` and populates it with the
|
||||
content of the `testrepo` directory.
|
||||
* `forgejo-test-helper.sh build_runner $forgejo/forgejo/runner v3.0.1`
|
||||
Builds the forgejo runner from source in `./forgejo-runner/forgejo-runner`.
|
||||
`export PATH=$(pwd)/forgejo-runner:$PATH` will ensure that calling `forgejo-runner.sh`
|
||||
will use this binary instead of downloading a released version of the runner.
|
||||
If the version is not specified, build from the main branch.
|
||||
|
||||
The combination of `push_self_action` and `run_workflow` allows to
|
||||
run Forgejo Actions workflows from `testrepo` that use the action
|
||||
|
|
1
RUNNER_REPOSITORY
Normal file
1
RUNNER_REPOSITORY
Normal file
|
@ -0,0 +1 @@
|
|||
https://code.forgejo.org/forgejo/runner
|
1
RUNNER_VERSION
Normal file
1
RUNNER_VERSION
Normal file
|
@ -0,0 +1 @@
|
|||
v3.0.1
|
|
@ -20,11 +20,6 @@ description: |
|
|||
* `forgejo-test-helper.sh push testrepo $forgejo root testrepo`
|
||||
Creates the repository `$forgejo/root/testrepo` and populates it with the
|
||||
content of the `testrepo` directory.
|
||||
* `forgejo-test-helper.sh build_runner $forgejo/forgejo/runner v3.0.1`
|
||||
Builds the forgejo runner from source in `./forgejo-runner/forgejo-runner`.
|
||||
`export PATH=$(pwd)/forgejo-runner:$PATH` will ensure that calling `forgejo-runner.sh`
|
||||
will use this binary instead of downloading a released version of the runner.
|
||||
If the version is not specified, build from the main branch.
|
||||
|
||||
The combination of `push_self_action` and `run_workflow` allows to
|
||||
run Forgejo Actions workflows from `testrepo` that use the action
|
||||
|
@ -47,10 +42,10 @@ inputs:
|
|||
description: 'Administrator password'
|
||||
default: 'admin1234'
|
||||
runner:
|
||||
description: 'Runner git repository'
|
||||
description: 'Runner repository'
|
||||
default: 'https://code.forgejo.org/forgejo/runner'
|
||||
runner-version:
|
||||
description: 'Runner version'
|
||||
description: 'Runner version. If it starts with @ (for instance @featurebranch), the runner will be built from source using the specified branch.'
|
||||
default: 'v3.0.1'
|
||||
container:
|
||||
description: 'Name of the container running the Forgejo instance'
|
||||
|
|
42
forgejo-runner-lib.sh
Normal file
42
forgejo-runner-lib.sh
Normal file
|
@ -0,0 +1,42 @@
|
|||
#!/bin/bash
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
set -ex
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
function dependency_go() {
|
||||
go_version="1.21.3.linux-amd64" # Set the desired Go version here
|
||||
|
||||
if ! which wget tar > /dev/null ; then
|
||||
apt-get install -y -qq wget tar
|
||||
fi
|
||||
|
||||
if ! which go > /dev/null ; then
|
||||
wget --quiet "https://go.dev/dl/go$go_version.tar.gz"
|
||||
tar zxf "go$go_version.tar.gz"
|
||||
export PATH="$(pwd)/go/bin:$PATH"
|
||||
fi
|
||||
}
|
||||
|
||||
function checkout() {
|
||||
local git="$1"
|
||||
git clone --depth 1 $git forgejo-runner
|
||||
}
|
||||
|
||||
function build_runner() {
|
||||
local git="$1"
|
||||
local version="${2:-main}"
|
||||
local dir=$(mktemp -d)
|
||||
(
|
||||
cd $dir
|
||||
checkout "$git"
|
||||
dependency_go
|
||||
cd forgejo-runner
|
||||
git checkout "$version"
|
||||
make build
|
||||
)
|
||||
mv $dir/forgejo-runner/forgejo-runner .
|
||||
./forgejo-runner --version
|
||||
rm -fr "$dir"
|
||||
}
|
|
@ -3,12 +3,15 @@
|
|||
|
||||
set -ex
|
||||
|
||||
PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}: '
|
||||
SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $SELF_DIR/forgejo-runner-lib.sh
|
||||
|
||||
: ${FORGEJO_RUNNER_CONFIG:=$SELF_DIR/runner-config.yaml}
|
||||
|
||||
function dependencies() {
|
||||
if ! which curl daemon > /dev/null ; then
|
||||
apt-get install -y -qq curl daemon
|
||||
if ! which make curl daemon > /dev/null ; then
|
||||
apt-get install -y -qq make curl daemon
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -49,12 +52,19 @@ function reload() {
|
|||
}
|
||||
|
||||
function setup() {
|
||||
local runner_repository="${1:-https://code.forgejo.org/forgejo/runner}"
|
||||
local version="${2:-v3.0.1}"
|
||||
local default_runner_repository="$(cat $SELF_DIR/RUNNER_REPOSITORY)"
|
||||
local runner_repository="${1:-${default_runner_repository}}"
|
||||
local default_version="$(cat $SELF_DIR/RUNNER_VERSION)"
|
||||
local version="${2:-${default_version}}"
|
||||
local forgejo="${3:-http://$(cat forgejo-ip):3000/}"
|
||||
|
||||
dependencies
|
||||
download $runner_repository $version
|
||||
if [[ "$version" =~ ^@ ]] ; then
|
||||
local branch=${version##@}
|
||||
build_runner $runner_repository $branch
|
||||
else
|
||||
download $runner_repository $version
|
||||
fi
|
||||
register $forgejo
|
||||
run
|
||||
}
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
|
||||
set -ex
|
||||
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
SELF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $SELF_DIR/forgejo-runner-lib.sh
|
||||
|
||||
: ${LOOPS:=80}
|
||||
: ${LOOP_DELAY:=5}
|
||||
|
@ -11,39 +12,6 @@ DIR=$(mktemp -d)
|
|||
|
||||
trap "rm -fr $DIR" EXIT
|
||||
|
||||
function dependency_go() {
|
||||
go_version="1.21.1.linux-amd64" # Set the desired Go version here
|
||||
|
||||
if ! which go > /dev/null ; then
|
||||
apt-get update
|
||||
apt-get install -y -qq wget tar
|
||||
wget --quiet "https://go.dev/dl/go$go_version.tar.gz"
|
||||
tar zxf "go$go_version.tar.gz"
|
||||
export PATH="$(pwd)/go/bin:$PATH"
|
||||
fi
|
||||
}
|
||||
|
||||
function checkout() {
|
||||
local git="$1"
|
||||
rm -fr forgejo-runner
|
||||
git clone $git forgejo-runner
|
||||
}
|
||||
|
||||
function build_runner() {
|
||||
local git="$1"
|
||||
local version="${2:-main}"
|
||||
|
||||
(
|
||||
checkout "$git"
|
||||
dependency_go
|
||||
cd forgejo-runner
|
||||
git checkout "$version"
|
||||
make build
|
||||
)
|
||||
export PATH=$PATH:$(pwd)/forgejo-runner
|
||||
forgejo-runner --version
|
||||
}
|
||||
|
||||
function branch_tip() {
|
||||
local url="$1"
|
||||
local repo="$2"
|
||||
|
|
17
utils/upgrade-runner.sh
Executable file
17
utils/upgrade-runner.sh
Executable file
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
set -e
|
||||
|
||||
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
|
||||
|
||||
REPOSITORY="$1"
|
||||
VERSION="$2"
|
||||
|
||||
echo $VERSION > $ROOT_DIR/RUNNER_VERSION
|
||||
sed -i -e 's^| runner-version | Runner version |.*^| runner-version | Runner version | `false` | '$VERSION' |^' $ROOT_DIR/README.md
|
||||
sed -i -e "/runner-version:/{n;n;s^.*default:.*^ default: '$VERSION'^}" $ROOT_DIR/action.yml
|
||||
|
||||
echo $REPOSITORY > $ROOT_DIR/RUNNER_REPOSITORY
|
||||
sed -i -e 's^| runner | Runner git repository |.*^| runner | Runner git repository | `false` | '$REPOSITORY' |^' $ROOT_DIR/README.md
|
||||
sed -i -e "/runner:/{n;n;s^.*default:.*^ default: '$REPOSITORY'^}" $ROOT_DIR/action.yml
|
Loading…
Reference in a new issue