Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Fold server tests into the lint workflow; prune script guards

Manav Rathie674ce774816
diff --git a/.github/workflows/server-lint.yml b/.github/workflows/server-lint.yml
index 3b2558d42f..ebc563f767 100644
--- a/.github/workflows/server-lint.yml
+++ b/.github/workflows/server-lint.yml
@@ -1,15 +1,18 @@
name: "Lint (Server)"
on:
- # Run on every pull request (open or push to it) that changes server/
pull_request:
paths:
- - "server/**"
- ".github/workflows/server-lint.yml"
+ - "server/**"
permissions:
contents: read
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: true
+
jobs:
lint:
runs-on: ubuntu-latest
@@ -27,8 +30,8 @@ jobs:
cache-dependency-path: server/go.sum
cache: true
- - name: Install dependencies
- run: sudo apt-get update && sudo apt-get install libsodium-dev
-
- name: Lint
- run: "./scripts/lint.sh"
+ run: ./scripts/lint.sh
+
+ - name: Test
+ run: ./scripts/test-with-postgres.sh docker
diff --git a/.github/workflows/server-test.yml b/.github/workflows/server-test.yml
deleted file mode 100644
index e5c6473760..0000000000
--- a/.github/workflows/server-test.yml
+++ /dev/null
@@ -1,35 +0,0 @@
-name: "Test (Server)"
-
-on:
- pull_request:
- paths:
- - "server/**"
- - ".github/workflows/server-test.yml"
-
-permissions:
- contents: read
-
-concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
-
-jobs:
- test:
- runs-on: ubuntu-latest
- defaults:
- run:
- working-directory: server
-
- steps:
- - name: Checkout
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
-
- - name: Setup go
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
- with:
- go-version-file: server/go.mod
- cache-dependency-path: server/go.sum
- cache: true
-
- - name: Run server tests
- run: ./scripts/test-with-postgres.sh docker
diff --git a/server/scripts/test-with-postgres.sh b/server/scripts/test-with-postgres.sh
index f5a975f817..bd71013d57 100755
--- a/server/scripts/test-with-postgres.sh
+++ b/server/scripts/test-with-postgres.sh
@@ -23,7 +23,7 @@ esac
if [ "$mode" = docker ]; then
container="ente-server-test-postgres-$$"
trap 'docker rm -f "$container" >/dev/null 2>&1 || true' EXIT INT TERM
- docker run --detach --rm \
+ docker run --detach \
--name "$container" \
--env POSTGRES_DB="$test_db" \
--env POSTGRES_PASSWORD=test_pass \
@@ -41,25 +41,9 @@ if [ "$mode" = docker ]; then
done
export PGHOST=localhost PGPORT="$port" PGUSER=postgres PGPASSWORD=test_pass
else
- # Guard the psql below from being redirected to a non-local cluster.
- [ -z "${DATABASE_URL:-}${PGSERVICE:-}${PGSERVICEFILE:-}" ] || {
- echo "Refusing DATABASE_URL/PGSERVICE/PGSERVICEFILE; they can redirect psql to another database." >&2
- exit 1
- }
- for host in "${PGHOST:-}" "${PGHOSTADDR:-}"; do
- case "$host" in
- "" | localhost | 127.0.0.1 | ::1 | /var/run/postgresql | /tmp) ;;
- *)
- [ "${ALLOW_NONLOCAL_TEST_DB:-}" = 1 ] || {
- echo "Refusing non-local Postgres target $host. Set ALLOW_NONLOCAL_TEST_DB=1 to override." >&2
- exit 1
- }
- ;;
- esac
- done
# psql defaults to the unix socket while lib/pq defaults to TCP
# localhost; pin both to the same server.
- [ -n "${PGHOST:-}${PGHOSTADDR:-}" ] || export PGHOST=localhost
+ [ -n "${PGHOST:-}" ] || export PGHOST=localhost
psql -qd postgres -c "CREATE DATABASE \"$test_db\""
trap 'psql -qd postgres -c "DROP DATABASE IF EXISTS \"$test_db\" WITH (FORCE)" >/dev/null 2>&1 || true' EXIT INT TERM
fi