Skip to content

Commit

Permalink
Improve CI (commune-sh#27)
Browse files Browse the repository at this point in the history

<!--
Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.
-->
  • Loading branch information
avdb13 authored Feb 14, 2024
1 parent d624217 commit 46f6134
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 134 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ COMMUNE_REGISTRATION_SHARED_SECRET='m@;wYOUOh0f:CH5XA65sJB1^q01~DmIriOysRImot,OR
# in the `access_tokens` table.
#
# Generate one using: `get_access_token` after running `just gen_synapse_admin_user`
COMMUNE_SYNAPSE_ADMIN_TOKEN=''
COMMUNE_SYNAPSE_ADMIN_TOKEN='null'
COMMUNE_SYNAPSE_HOST='http://0.0.0.0:8008'
# Found in the homeserver.yaml file
COMMUNE_SYNAPSE_SERVER_NAME='matrix.localhost'
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ jobs:
- name: Create a copy of `.env.example`
run: just dotenv

- name: Generate Synapse Configuration
run: |
just gen_synapse_conf
- name: Set environment variable
run: echo "DOCKER_USER='$(id -u):$(id -g)'" >> .env

- name: Use Test Homeserver
run: |
sudo cp -f ./crates/test/fixtures/synapse/homeserver.yaml ./docker/synapse/homeserver.yaml
mkdir -p ./docker/synapse
cp ./crates/test/fixtures/synapse/* ./docker/synapse
- name: Run Docker Containers
run: |
Expand All @@ -77,14 +77,13 @@ jobs:
- name: Retrieve Admin Access Token
run: |
just get_access_token
export COMMUNE_SYNAPSE_ADMIN_TOKEN=$(cat ./access_token.txt)
echo "COMMUNE_SYNAPSE_ADMIN_TOKEN=${COMMUNE_SYNAPSE_ADMIN_TOKEN}" >> $GITHUB_ENV
grep 'COMMUNE_SYNAPSE_ADMIN_TOKEN' .env >> $GITHUB_ENV
- name: E2E Tests
env:
COMMUNE_SYNAPSE_ADMIN_TOKEN: ${{ env.COMMUNE_SYNAPSE_ADMIN_TOKEN }}
run: |
cargo test -p test -- --test-threads=1
just e2e -- --show-output
- name: Print Logs
if: always()
Expand Down
20 changes: 0 additions & 20 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,6 @@ You must run Docker services as for development. In order to avoid messing up
the development environment, its recommended to use the synapse setup from
`crates/test/fixtures/synapse` replacing it with `docker/synapse`.

The only difference should be the `database` section, which uses SQLite instead.

```diff
database:
+ name: psycopg2
+ args:
+ database: /data/homeserver.db
- name: psycopg2
- txn_limit: 10000
- allow_unsafe_locale: true
- args:
- user: synapse_user
- password: secretpassword
- database: synapse
- host: localhost
- port: 5432
- cp_min: 5
- cp_max: 10
```

> Make sure the `.env` file is created from the contents on `.env.example`
### Application Layout
Expand Down
13 changes: 11 additions & 2 deletions crates/test/fixtures/synapse/homeserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@ listeners:
- names: [client, federation]
compress: false
database:
name: sqlite3
name: psycopg2
txn_limit: 10000
allow_unsafe_locale: true
args:
database: /data/homeserver.db
user: synapse_user
password: secretpassword
database: synapse
host: localhost
port: 5432
cp_min: 5
cp_max: 10
log_config: "/data/matrix.localhost.log.config"
media_store_path: /data/media_store
registration_shared_secret: "m@;wYOUOh0f:CH5XA65sJB1^q01~DmIriOysRImot,OR_vzN&B"
Expand Down Expand Up @@ -70,4 +78,5 @@ rc_invites:
per_user:
per_second: 1000
burst_count: 1000

# vim:ft=yaml
30 changes: 13 additions & 17 deletions crates/test/fixtures/synapse/matrix.localhost.log.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,34 @@ version: 1

formatters:
precise:

format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s'


handlers:

file:
class: logging.handlers.TimedRotatingFileHandler
formatter: precise
filename: /data/homeserver.log
when: midnight
backupCount: 3
encoding: utf8

buffer:
class: synapse.logging.handlers.PeriodicallyFlushingMemoryHandler
target: file
capacity: 10

console:
class: logging.StreamHandler
formatter: precise

loggers:
# This is just here so we can leave `loggers` in the config regardless of whether
# we configure other loggers below (avoid empty yaml dict error).
_placeholder:
level: "INFO"



synapse.storage.SQL:
# beware: increasing this to DEBUG will make synapse log sensitive
# information such as access tokens.
level: INFO




root:
level: INFO


handlers: [console]


disable_existing_loggers: false
disable_existing_loggers: false
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ services:

synapse:
image: 'ghcr.io/element-hq/synapse:v1.100.0'
user: '${UID:-1000}:${GID:-1000}'
user: '${DOCKER_USER}'
ports:
- '8008:8008'
- '8448:8448'
Expand Down
Empty file removed docker/.gitkeep
Empty file.
Empty file removed docker/synapse/.gitkeep
Empty file.
46 changes: 0 additions & 46 deletions fixtures/synapse/homeserver.yaml

This file was deleted.

39 changes: 0 additions & 39 deletions fixtures/synapse/matrix.localhost.log.config

This file was deleted.

1 change: 0 additions & 1 deletion fixtures/synapse/matrix.localhost.signing.key

This file was deleted.

0 comments on commit 46f6134

Please sign in to comment.