Skip to content

corporate bodies AND fix CI #41

corporate bodies AND fix CI

corporate bodies AND fix CI #41

Workflow file for this run

name: MyEnergy Build and Test
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
jobs:
test:
runs-on: ubuntu-latest
services:
timescaledb:
image: timescale/timescaledb-ha:pg17
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: tsdb
ports:
- 25432:5432
options: >-
--health-cmd "pg_isready -U postgres"
--health-interval 10s
--health-timeout 5s
--health-retries 10
steps:
- uses: actions/checkout@v4
- name: Sqitch install
run: docker pull sqitch/sqitch && curl -L https://git.io/JJKCn -o /usr/local/bin/sqitch && chmod +x /usr/local/bin/sqitch && sqitch --help
- name: Setup DB
run: |
docker run --rm --network host postgres:17-alpine psql \
"postgresql://postgres:postgres@localhost:25432/postgres" \
-c "DO \$\$ BEGIN IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname='tsdbadmin') THEN CREATE ROLE tsdbadmin LOGIN SUPERUSER PASSWORD 'tsdbadmin'; ELSE ALTER USER tsdbadmin WITH PASSWORD 'tsdbadmin'; END IF; END \$\$;"
docker run --rm --network host \
-v "$(pwd)/sqitch:/sqitch" postgres:17-alpine \
psql "postgresql://tsdbadmin:tsdbadmin@localhost:25432/tsdb" \
-f /sqitch/ci-bootstrap.sql
- name: Checkout flows-db
uses: actions/checkout@v4
with:
repository: cepro/simt-flows-db
path: flows-db
- name: Flows migrations
run: |
cd flows-db/sqitch && sqitch deploy "db:pg://tsdbadmin:tsdbadmin@localhost:25432/tsdb" \
--set flows_password=flows \
--set grafanareader_password=grafanareader \
--set tableau_password=tableau \
--set env=ci \
--verbose && cd -
- name: Flows seed
run: |
docker run --rm --network host postgres:17-alpine \
psql "postgresql://tsdbadmin:tsdbadmin@localhost:25432/tsdb" -c "
INSERT INTO flows.escos (id, created_at, name, code, app_url) VALUES
('612a3f01-dfde-4458-bd0b-bfb9aa7d3668', now(), 'Abolish Empty Office Buildings', 'aeob', NULL),
('2995cc75-1fa6-46ef-aae1-7807f5721765', now(), 'Bristol Energy Coop', 'bec', NULL),
('3396e0c8-62e5-4902-a9e2-2d6505b2cb8c', now(), 'Bristol Power Cooperative', 'bpc', NULL),
('68456b3f-35c6-44f1-9f14-563ab64e8ceb', now(), 'Lab', 'lab', NULL),
('363ff821-3a56-4b43-8227-8e53c45fbcdb', now(), 'Hazelmead', 'hmce', 'http://0.0.0.0:4242'),
('6688351f-c47a-441b-ad3f-b3dabadf2bca', now(), 'London Fields', 'lfce', NULL),
('01da4a58-9a2e-440a-b8ac-2f36038484d2', now(), 'Owen Square', 'osce', NULL),
('f6bcd195-6528-426b-a6f0-ce2af6a37494', now(), 'Trent Basin', 'tbce', NULL),
('527eed5d-2f81-4abe-a7f4-6fff8ac72703', now(), 'Water Lilies', 'wlce', 'http://0.0.0.0:4242')
ON CONFLICT DO NOTHING;"
- name: Migrations
run: |
cd sqitch && sqitch deploy --target timescale-ci \
--set postgraphile_password=postgraphile \
--verbose && cd -
# uncomment the following to be able to ssh in and investigate an issue:
#
# - name: Setup tmate session
# if: success() || failure()
# uses: mxschmitt/action-tmate@v3
- name: create .pgpass for seed script
run: mkdir -p /tmp/psql-script/ && echo "*:*:*:tsdbadmin:tsdbadmin" > /tmp/psql-script/.pgpass && chmod 0600 /tmp/psql-script/.pgpass
- name: Seed
run: bin/seed
- name: Test
env:
PGPASSWORD: tsdbadmin
run: bin/test
# TODO: Was using supabase lint - replace with something else
# - name: Lint
# run: bin/supa-lint