Skip to content

Prepare and check test env during CI #17725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 34 additions & 14 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
kind: pipeline
type: docker
name: compliance

platform:
Expand Down Expand Up @@ -130,6 +131,7 @@ steps:

---
kind: pipeline
type: docker
name: testing-amd64

platform:
Expand Down Expand Up @@ -191,26 +193,30 @@ steps:
exclude:
- pull_request

- name: build
pull: always
image: golang:1.17
commands:
- make backend
environment:
GOPROXY: https://goproxy.cn # proxy.golang.org is blocked in China, this proxy is not
GOSUMDB: sum.golang.org
TAGS: bindata sqlite sqlite_unlock_notify

- name: tag-pre-condition
pull: always
image: drone/git
commands:
- git update-ref refs/heads/tag_test ${DRONE_COMMIT_SHA}

- name: fix-permissions
- name: prepare-test-env
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env
commands:
- chown -R gitea:gitea .
- ./build/test-env-prepare.sh

- name: build
pull: always
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env
user: gitea
commands:
- ./build/test-env-check.sh
- make backend
environment:
GOPROXY: https://goproxy.cn # proxy.golang.org is blocked in China, this proxy is not
GOSUMDB: sum.golang.org
TAGS: bindata sqlite sqlite_unlock_notify
depends_on:
- prepare-test-env

- name: unit-test
image: gitea/test_env:linux-amd64 # https://gitea.com/gitea/test-env
Expand Down Expand Up @@ -353,21 +359,24 @@ steps:
exclude:
- pull_request

- name: fix-permissions
- name: prepare-test-env
image: gitea/test_env:linux-arm64 # https://gitea.com/gitea/test-env
commands:
- chown -R gitea:gitea .
- ./build/test-env-prepare.sh

- name: build
pull: always
image: gitea/test_env:linux-arm64 # https://gitea.com/gitea/test-env
user: gitea
commands:
- ./build/test-env-check.sh
- make backend
environment:
GOPROXY: https://goproxy.cn # proxy.golang.org is blocked in China, this proxy is not
GOSUMDB: sum.golang.org
TAGS: bindata gogit sqlite sqlite_unlock_notify
depends_on:
- prepare-test-env

- name: test-sqlite
image: gitea/test_env:linux-arm64 # https://gitea.com/gitea/test-env
Expand Down Expand Up @@ -461,6 +470,7 @@ steps:

---
kind: pipeline
type: docker
name: update_gitignore_and_licenses

platform:
Expand Down Expand Up @@ -497,6 +507,7 @@ steps:

---
kind: pipeline
type: docker
name: release-latest

platform:
Expand Down Expand Up @@ -675,6 +686,7 @@ steps:

---
kind: pipeline
type: docker
name: docs

platform:
Expand Down Expand Up @@ -716,6 +728,7 @@ steps:

---
kind: pipeline
type: docker
name: docker-linux-amd64-release-version

platform:
Expand Down Expand Up @@ -780,6 +793,7 @@ steps:

---
kind: pipeline
type: docker
name: docker-linux-amd64-release

platform:
Expand Down Expand Up @@ -844,6 +858,7 @@ steps:

---
kind: pipeline
type: docker
name: docker-linux-arm64-dry-run

platform:
Expand Down Expand Up @@ -876,6 +891,7 @@ steps:

---
kind: pipeline
type: docker
name: docker-linux-arm64-release-version

platform:
Expand Down Expand Up @@ -943,6 +959,7 @@ steps:

---
kind: pipeline
type: docker
name: docker-linux-arm64-release

platform:
Expand Down Expand Up @@ -1009,6 +1026,7 @@ steps:
- pull_request
---
kind: pipeline
type: docker
name: docker-manifest-version

platform:
Expand Down Expand Up @@ -1052,6 +1070,7 @@ depends_on:

---
kind: pipeline
type: docker
name: docker-manifest

platform:
Expand Down Expand Up @@ -1095,6 +1114,7 @@ depends_on:

---
kind: pipeline
type: docker
name: notifications

platform:
Expand Down
24 changes: 24 additions & 0 deletions build/test-env-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/sh

set -e

if [ ! -f ./build/test-env-check.sh ]; then
echo "${0} can only be executed in gitea source root directory"
exit 1
fi


echo "check uid ..."

# the uid of gitea defined in "https://gitea.com/gitea/test-env" is 1000
gitea_uid=$(id -u gitea)
if [ "$gitea_uid" != "1000" ]; then
echo "The uid of linux user 'gitea' is expected to be 1000, but it is $gitea_uid"
exit 1
fi

cur_uid=$(id -u)
if [ "$cur_uid" != "0" -a "$cur_uid" != "$gitea_uid" ]; then
echo "The uid of current linux user is expected to be 0 or $gitea_uid, but it is $cur_uid"
exit 1
fi
11 changes: 11 additions & 0 deletions build/test-env-prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh

set -e

if [ ! -f ./build/test-env-prepare.sh ]; then
echo "${0} can only be executed in gitea source root directory"
exit 1
fi

echo "change the owner of files to gitea ..."
chown -R gitea:gitea .