chore: fix ci
This commit is contained in:
parent
0db5ca4523
commit
0b9c597ca4
22
.gitea/Dockerfile.ci-runner
Normal file
22
.gitea/Dockerfile.ci-runner
Normal file
@ -0,0 +1,22 @@
|
||||
FROM node:20-bookworm
|
||||
|
||||
ENV PIP_BREAK_SYSTEM_PACKAGES 1
|
||||
|
||||
RUN apt-get update && apt-get upgrade -y
|
||||
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata \
|
||||
&& apt-get install -y curl ca-certificates gnupg postgresql-common \
|
||||
&& YES=y sh /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh \
|
||||
&& apt-get install -y postgresql-15
|
||||
RUN apt-get update \
|
||||
&& install -m 0755 -d /etc/apt/keyrings \
|
||||
&& curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg \
|
||||
&& chmod a+r /etc/apt/keyrings/docker.gpg \
|
||||
&& echo \
|
||||
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
|
||||
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null \
|
||||
&& apt-get update \
|
||||
&& apt-get install -y docker-ce-cli docker-compose-plugin
|
||||
RUN set -x \
|
||||
&& apt-get install -y python3 python3-pip \
|
||||
&& pip install psycopg2-binary \
|
||||
&& pip install migra
|
@ -3,29 +3,13 @@ on: {push: {branches: ['main']}}
|
||||
|
||||
jobs:
|
||||
migrate-devel:
|
||||
container:
|
||||
image: 'git.orionkindel.com/dnim/db-ci-runner:disheveled-iceberg-launched-loosely'
|
||||
volumes: ['/run/user/1001/docker.sock:/run/user/1001/docker.sock']
|
||||
steps:
|
||||
- uses: 'actions/checkout@v3'
|
||||
- name: 'install postgres'
|
||||
run: |
|
||||
apt-get update
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata
|
||||
apt-get install -y curl ca-certificates gnupg postgresql-common
|
||||
YES=y sh /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
|
||||
apt-get install -y postgresql-15
|
||||
- name: 'install docker-ce-cli'
|
||||
run: |
|
||||
apt-get update
|
||||
install -m 0755 -d /etc/apt/keyrings
|
||||
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||
chmod a+r /etc/apt/keyrings/docker.gpg
|
||||
echo \
|
||||
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
|
||||
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
|
||||
tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||
apt-get update
|
||||
apt-get install -y docker-ce-cli docker-compose-plugin
|
||||
stat /var/run/docker.sock
|
||||
|
||||
- run: './scripts/migrate.sh'
|
||||
with: { fetch-depth: 0 }
|
||||
- run: './scripts/migrate.sh --greenlight'
|
||||
env:
|
||||
DOCKER_HOST: 'unix:///run/user/1001/docker.sock'
|
||||
POSTGRES_URI: '${{ secrets.POSTGRES_DEVEL_URI }}'
|
||||
|
@ -1,17 +1,15 @@
|
||||
name: 'migrate-devel'
|
||||
name: 'migrate-stage'
|
||||
on: {push: {branches: ['main']}}
|
||||
|
||||
jobs:
|
||||
migrate-devel:
|
||||
env:
|
||||
POSTGRES_URI: '${{ secrets.devel_postgres_uri }}'
|
||||
migrate-stage:
|
||||
container:
|
||||
image: 'git.orionkindel.com/dnim/db-ci-runner:disheveled-iceberg-launched-loosely'
|
||||
volumes: ['/run/user/1001/docker.sock:/run/user/1001/docker.sock']
|
||||
steps:
|
||||
- uses: 'actions/checkout@v3'
|
||||
- name: 'install postgres'
|
||||
run: |
|
||||
apt-get update
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata
|
||||
apt-get install -y curl ca-certificates gnupg postgresql-common
|
||||
YES=y sh /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
|
||||
apt-get install -y postgresql-15
|
||||
- run: './scripts/migrate.sh'
|
||||
with: { fetch-depth: 0 }
|
||||
- run: './scripts/migrate.sh --greenlight'
|
||||
env:
|
||||
DOCKER_HOST: 'unix:///run/user/1001/docker.sock'
|
||||
POSTGRES_URI: '${{ secrets.POSTGRES_STAGE_URI }}'
|
||||
|
@ -1,5 +1,7 @@
|
||||
#! /bin/bash
|
||||
|
||||
set -ex
|
||||
|
||||
source ./scripts/env.sh ./.env.schema
|
||||
|
||||
rev=${1:-HEAD}
|
||||
@ -14,7 +16,7 @@ if [[ "$rev" = "HEAD" ]]; then
|
||||
port=5432
|
||||
else
|
||||
head=$(git show --format=format:%h -q)
|
||||
git reset "$rev" --quiet --hard
|
||||
git reset --quiet --hard "$rev"
|
||||
port=5433
|
||||
fi
|
||||
|
||||
@ -34,6 +36,6 @@ psql --quiet "$url/postgres" --file="$dropdb" 1>/dev/null
|
||||
ls ./schema/ | xargs -I{} \
|
||||
psql \
|
||||
--quiet \
|
||||
"$url/$POSTGRES_DB" \
|
||||
"$url/dnim" \
|
||||
--file=./schema/{} \
|
||||
1>/dev/null
|
||||
|
@ -1,23 +1,25 @@
|
||||
#! /bin/bash
|
||||
|
||||
set -e
|
||||
set -ex
|
||||
|
||||
source ./scripts/env.sh ./.env.schema
|
||||
|
||||
rev=${1:-}
|
||||
|
||||
head_url=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/$POSTGRES_DB
|
||||
base_url=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5433/$POSTGRES_DB
|
||||
head_url=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/dnim
|
||||
base_url=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5433/dnim
|
||||
|
||||
if [[ -z "$rev" ]]; then
|
||||
echo "revision to diff is required";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
docker compose up -d
|
||||
docker compose up 1>&2 &
|
||||
|
||||
./scripts/build.sh $rev
|
||||
./scripts/build.sh HEAD
|
||||
|
||||
echo "migrate from $rev => HEAD" 1>&2
|
||||
migra --unsafe $base_url $head_url || echo "migra exited with code $?. this is /probably/ fine" 1>&2
|
||||
|
||||
docker compose down 1>&2
|
||||
|
@ -28,6 +28,7 @@ else
|
||||
if [[ "$1" = "--greenlight" ]]; then
|
||||
psql "$POSTGRES_URI/dnim" -c "$script"
|
||||
else
|
||||
mkdir -p tmp
|
||||
to_review="tmp/migrate_${last_revision}_to_${head}.sql"
|
||||
echo "$script" > "$to_review"
|
||||
echo "script written to $to_review"
|
||||
|
Loading…
Reference in New Issue
Block a user