Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • maunium/synapse
  • leytilera/synapse
2 results
Show changes
Commits on Source (2938)
Showing
with 253 additions and 176 deletions
#!/bin/sh
set -xeu
# On 32-bit Linux platforms, we need libatomic1 to use rustup
if command -v yum &> /dev/null; then
yum install -y libatomic
fi
# Install a Rust toolchain
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain 1.82.0 -y --profile minimal
#!/usr/bin/env python #!/usr/bin/env python
# Copyright 2022 The Matrix.org Foundation C.I.C.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # This file is licensed under the Affero General Public License (AGPL) version 3.
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at # Copyright (C) 2023 New Vector, Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# See the GNU Affero General Public License for more details:
# <https://www.gnu.org/licenses/agpl-3.0.html>.
#
# Originally licensed under the Apache License, Version 2.0:
# <http://www.apache.org/licenses/LICENSE-2.0>.
#
# [This file includes modifications made by New Vector Limited]
# #
# http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Wraps `auditwheel repair` to first check if we're repairing a potentially abi3 # Wraps `auditwheel repair` to first check if we're repairing a potentially abi3
# compatible wheel, if so rename the wheel before repairing it. # compatible wheel, if so rename the wheel before repairing it.
...@@ -50,7 +56,16 @@ def cpython(wheel_file: str, name: str, version: Version, tag: Tag) -> str: ...@@ -50,7 +56,16 @@ def cpython(wheel_file: str, name: str, version: Version, tag: Tag) -> str:
check_is_abi3_compatible(wheel_file) check_is_abi3_compatible(wheel_file)
abi3_tag = Tag(tag.interpreter, "abi3", tag.platform) # HACK: it seems that some older versions of pip will consider a wheel marked
# as macosx_11_0 as incompatible with Big Sur. I haven't done the full archaeology
# here; there are some clues in
# https://github.com/pantsbuild/pants/pull/12857
# https://github.com/pypa/pip/issues/9138
# https://github.com/pypa/packaging/pull/319
# Empirically this seems to work, note that macOS 11 and 10.16 are the same,
# both versions are valid for backwards compatibility.
platform = tag.platform.replace("macosx_11_0", "macosx_10_16")
abi3_tag = Tag(tag.interpreter, "abi3", platform)
dirname = os.path.dirname(wheel_file) dirname = os.path.dirname(wheel_file)
new_wheel_file = os.path.join( new_wheel_file = os.path.join(
......
#!/usr/bin/env python #!/usr/bin/env python
# Copyright 2022 The Matrix.org Foundation C.I.C.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # This file is licensed under the Affero General Public License (AGPL) version 3.
# you may not use this file except in compliance with the License. #
# You may obtain a copy of the License at # Copyright (C) 2023 New Vector, Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# See the GNU Affero General Public License for more details:
# <https://www.gnu.org/licenses/agpl-3.0.html>.
#
# Originally licensed under the Apache License, Version 2.0:
# <http://www.apache.org/licenses/LICENSE-2.0>.
#
# [This file includes modifications made by New Vector Limited]
# #
# http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Calculate the trial jobs to run based on if we're in a PR or not. # Calculate the trial jobs to run based on if we're in a PR or not.
...@@ -29,11 +35,12 @@ IS_PR = os.environ["GITHUB_REF"].startswith("refs/pull/") ...@@ -29,11 +35,12 @@ IS_PR = os.environ["GITHUB_REF"].startswith("refs/pull/")
# First calculate the various trial jobs. # First calculate the various trial jobs.
# #
# For each type of test we only run on Py3.7 on PRs # For PRs, we only run each type of test with the oldest Python version supported (which
# is Python 3.9 right now)
trial_sqlite_tests = [ trial_sqlite_tests = [
{ {
"python-version": "3.7", "python-version": "3.9",
"database": "sqlite", "database": "sqlite",
"extras": "all", "extras": "all",
} }
...@@ -46,15 +53,14 @@ if not IS_PR: ...@@ -46,15 +53,14 @@ if not IS_PR:
"database": "sqlite", "database": "sqlite",
"extras": "all", "extras": "all",
} }
for version in ("3.8", "3.9", "3.10") for version in ("3.10", "3.11", "3.12", "3.13")
) )
trial_postgres_tests = [ trial_postgres_tests = [
{ {
"python-version": "3.7", "python-version": "3.9",
"database": "postgres", "database": "postgres",
"postgres-version": "10", "postgres-version": "13",
"extras": "all", "extras": "all",
} }
] ]
...@@ -62,16 +68,16 @@ trial_postgres_tests = [ ...@@ -62,16 +68,16 @@ trial_postgres_tests = [
if not IS_PR: if not IS_PR:
trial_postgres_tests.append( trial_postgres_tests.append(
{ {
"python-version": "3.10", "python-version": "3.13",
"database": "postgres", "database": "postgres",
"postgres-version": "14", "postgres-version": "17",
"extras": "all", "extras": "all",
} }
) )
trial_no_extra_tests = [ trial_no_extra_tests = [
{ {
"python-version": "3.7", "python-version": "3.9",
"database": "sqlite", "database": "sqlite",
"extras": "", "extras": "",
} }
...@@ -93,35 +99,45 @@ set_output("trial_test_matrix", test_matrix) ...@@ -93,35 +99,45 @@ set_output("trial_test_matrix", test_matrix)
# First calculate the various sytest jobs. # First calculate the various sytest jobs.
# #
# For each type of test we only run on focal on PRs # For each type of test we only run on bullseye on PRs
sytest_tests = [ sytest_tests = [
{ {
"sytest-tag": "focal", "sytest-tag": "bullseye",
}, },
{ {
"sytest-tag": "focal", "sytest-tag": "bullseye",
"postgres": "postgres", "postgres": "postgres",
}, },
{ {
"sytest-tag": "focal", "sytest-tag": "bullseye",
"postgres": "multi-postgres", "postgres": "multi-postgres",
"workers": "workers", "workers": "workers",
}, },
{
"sytest-tag": "bullseye",
"postgres": "multi-postgres",
"workers": "workers",
"reactor": "asyncio",
},
] ]
if not IS_PR: if not IS_PR:
sytest_tests.extend( sytest_tests.extend(
[ [
{ {
"sytest-tag": "testing", "sytest-tag": "bullseye",
"reactor": "asyncio",
},
{
"sytest-tag": "bullseye",
"postgres": "postgres", "postgres": "postgres",
"reactor": "asyncio",
}, },
{ {
"sytest-tag": "buster", "sytest-tag": "testing",
"postgres": "multi-postgres", "postgres": "postgres",
"workers": "workers",
}, },
] ]
) )
......
#! /usr/bin/env python
import sys
if sys.version_info < (3, 11):
raise RuntimeError("Requires at least Python 3.11, to import tomllib")
import tomllib
with open("poetry.lock", "rb") as f:
lockfile = tomllib.load(f)
try:
lock_version = lockfile["metadata"]["lock-version"]
assert lock_version == "2.0"
except Exception:
print(
"""\
Lockfile is not version 2.0. You probably need to upgrade poetry on your local box
and re-run `poetry lock --no-update`. See the Poetry cheat sheet at
https://element-hq.github.io/synapse/develop/development/dependencies.html
"""
)
raise
#!/usr/bin/env bash #!/usr/bin/env bash
# this script is run by GitHub Actions in a plain `focal` container; it # this script is run by GitHub Actions in a plain `jammy` container; it
# - installs the minimal system requirements, and poetry; # - installs the minimal system requirements, and poetry;
# - patches the project definition file to refer to old versions only; # - patches the project definition file to refer to old versions only;
# - creates a venv with these old versions using poetry; and finally # - creates a venv with these old versions using poetry; and finally
...@@ -31,34 +31,6 @@ sed -i \ ...@@ -31,34 +31,6 @@ sed -i \
-e '/systemd/d' \ -e '/systemd/d' \
pyproject.toml pyproject.toml
# Use poetry to do the installation. This ensures that the versions are all mutually
# compatible (as far the package metadata declares, anyway); pip's package resolver
# is more lax.
#
# Rather than `poetry install --no-dev`, we drop all dev dependencies from the
# toml file. This means we don't have to ensure compatibility between old deps and
# dev tools.
pip install toml wheel
REMOVE_DEV_DEPENDENCIES="
import toml
with open('pyproject.toml', 'r') as f:
data = toml.loads(f.read())
del data['tool']['poetry']['dev-dependencies']
with open('pyproject.toml', 'w') as f:
toml.dump(data, f)
"
python3 -c "$REMOVE_DEV_DEPENDENCIES"
pip install poetry==1.2.0
poetry lock
echo "::group::Patched pyproject.toml" echo "::group::Patched pyproject.toml"
cat pyproject.toml cat pyproject.toml
echo "::endgroup::" echo "::endgroup::"
echo "::group::Lockfile after patch"
cat poetry.lock
echo "::endgroup::"
...@@ -9,19 +9,9 @@ set -eu ...@@ -9,19 +9,9 @@ set -eu
alias block='{ set +x; } 2>/dev/null; func() { echo "::group::$*"; set -x; }; func' alias block='{ set +x; } 2>/dev/null; func() { echo "::group::$*"; set -x; }; func'
alias endblock='{ set +x; } 2>/dev/null; func() { echo "::endgroup::"; set -x; }; func' alias endblock='{ set +x; } 2>/dev/null; func() { echo "::endgroup::"; set -x; }; func'
block Set Go Version
# The path is set via a file given by $GITHUB_PATH. We need both Go 1.17 and GOPATH on the path to run Complement.
# See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-system-path
# Add Go 1.17 to the PATH: see https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md#environment-variables-2
echo "$GOROOT_1_17_X64/bin" >> $GITHUB_PATH
# Add the Go path to the PATH: We need this so we can call gotestfmt
echo "~/go/bin" >> $GITHUB_PATH
endblock
block Install Complement Dependencies block Install Complement Dependencies
sudo apt-get -qq update && sudo apt-get install -qqy libolm3 libolm-dev sudo apt-get -qq update && sudo apt-get install -qqy libolm3 libolm-dev
go get -v github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest go install -v github.com/gotesttools/gotestfmt/v2/cmd/gotestfmt@latest
endblock endblock
block Install custom gotestfmt template block Install custom gotestfmt template
......
...@@ -23,8 +23,9 @@ poetry run python -m synapse.app.admin_cmd -c .ci/sqlite-config.yaml export-dat ...@@ -23,8 +23,9 @@ poetry run python -m synapse.app.admin_cmd -c .ci/sqlite-config.yaml export-dat
--output-directory /tmp/export_data --output-directory /tmp/export_data
# Test that the output directory exists and contains the rooms directory # Test that the output directory exists and contains the rooms directory
dir="/tmp/export_data/rooms" dir_r="/tmp/export_data/rooms"
if [ -d "$dir" ]; then dir_u="/tmp/export_data/user_data"
if [ -d "$dir_r" ] && [ -d "$dir_u" ]; then
echo "Command successful, this test passes" echo "Command successful, this test passes"
else else
echo "No output directories found, the command fails against a sqlite database." echo "No output directories found, the command fails against a sqlite database."
...@@ -43,8 +44,9 @@ poetry run python -m synapse.app.admin_cmd -c .ci/postgres-config.yaml export-d ...@@ -43,8 +44,9 @@ poetry run python -m synapse.app.admin_cmd -c .ci/postgres-config.yaml export-d
--output-directory /tmp/export_data2 --output-directory /tmp/export_data2
# Test that the output directory exists and contains the rooms directory # Test that the output directory exists and contains the rooms directory
dir2="/tmp/export_data2/rooms" dir_r2="/tmp/export_data2/rooms"
if [ -d "$dir2" ]; then dir_u2="/tmp/export_data2/user_data"
if [ -d "$dir_r2" ] && [ -d "$dir_u2" ]; then
echo "Command successful, this test passes" echo "Command successful, this test passes"
else else
echo "No output directories found, the command fails against a postgres database." echo "No output directories found, the command fails against a postgres database."
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
!README.rst !README.rst
!pyproject.toml !pyproject.toml
!poetry.lock !poetry.lock
!requirements.txt
!Cargo.lock !Cargo.lock
!Cargo.toml !Cargo.toml
!build_rust.py !build_rust.py
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
root = true root = true
# 4 space indentation # 4 space indentation
[*.py] [*.{py,pyi}]
indent_style = space indent_style = space
indent_size = 4 indent_size = 4
max_line_length = 88 max_line_length = 88
# TODO: incorporate this into pyproject.toml if flake8 supports it in the future.
# See https://github.com/PyCQA/flake8/issues/234
[flake8]
# see https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes
# for error codes. The ones we ignore are:
# W503: line break before binary operator
# W504: line break after binary operator
# E203: whitespace before ':' (which is contrary to pep8?)
# E731: do not assign a lambda expression, use a def
# E501: Line too long (black enforces this for us)
#
# flake8-bugbear runs extra checks. Its error codes are described at
# https://github.com/PyCQA/flake8-bugbear#list-of-warnings
# B019: Use of functools.lru_cache or functools.cache on methods can lead to memory leaks
# B023: Functions defined inside a loop must not use variables redefined in the loop
# B024: Abstract base class with no abstract method.
ignore=W503,W504,E203,E731,E501,B019,B023,B024
...@@ -8,17 +8,21 @@ ...@@ -8,17 +8,21 @@
# If ignoring a pull request that was not squash merged, only the merge # If ignoring a pull request that was not squash merged, only the merge
# commit needs to be put here. Child commits will be resolved from it. # commit needs to be put here. Child commits will be resolved from it.
# Run black (#3679). # Run black (https://github.com/matrix-org/synapse/pull/3679).
8b3d9b6b199abb87246f982d5db356f1966db925 8b3d9b6b199abb87246f982d5db356f1966db925
# Black reformatting (#5482). # Black reformatting (https://github.com/matrix-org/synapse/pull/5482).
32e7c9e7f20b57dd081023ac42d6931a8da9b3a3 32e7c9e7f20b57dd081023ac42d6931a8da9b3a3
# Target Python 3.5 with black (#8664). # Target Python 3.5 with black (https://github.com/matrix-org/synapse/pull/8664).
aff1eb7c671b0a3813407321d2702ec46c71fa56 aff1eb7c671b0a3813407321d2702ec46c71fa56
# Update black to 20.8b1 (#9381). # Update black to 20.8b1 (https://github.com/matrix-org/synapse/pull/9381).
0a00b7ff14890987f09112a2ae696c61001e6cf1 0a00b7ff14890987f09112a2ae696c61001e6cf1
# Convert tests/rest/admin/test_room.py to unix file endings (#7953). # Convert tests/rest/admin/test_room.py to unix file endings (https://github.com/matrix-org/synapse/pull/7953).
c4268e3da64f1abb5b31deaeb5769adb6510c0a7 c4268e3da64f1abb5b31deaeb5769adb6510c0a7
\ No newline at end of file
# Update black to 23.1.0 (https://github.com/matrix-org/synapse/pull/15103)
9bb2eac71962970d02842bca441f4bcdbbf93a11
# Automatically request reviews from the synapse-core team when a pull request comes in. # Automatically request reviews from the synapse-core team when a pull request comes in.
* @matrix-org/synapse-core * @element-hq/synapse-core
\ No newline at end of file
# One username per supported platform and one custom link
patreon: matrixdotorg
liberapay: matrixdotorg
custom: https://paypal.me/matrixdotorg
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
(using a matrix.org account if necessary). We do not use GitHub issues for (using a matrix.org account if necessary). We do not use GitHub issues for
support. support.
**If you want to report a security issue** please see https://matrix.org/security-disclosure-policy/ **If you want to report a security issue** please see https://element.io/security/security-disclosure-policy
...@@ -7,7 +7,7 @@ body: ...@@ -7,7 +7,7 @@ body:
**THIS IS NOT A SUPPORT CHANNEL!** **THIS IS NOT A SUPPORT CHANNEL!**
**IF YOU HAVE SUPPORT QUESTIONS ABOUT RUNNING OR CONFIGURING YOUR OWN HOME SERVER**, please ask in **[#synapse:matrix.org](https://matrix.to/#/#synapse:matrix.org)** (using a matrix.org account if necessary). **IF YOU HAVE SUPPORT QUESTIONS ABOUT RUNNING OR CONFIGURING YOUR OWN HOME SERVER**, please ask in **[#synapse:matrix.org](https://matrix.to/#/#synapse:matrix.org)** (using a matrix.org account if necessary).
If you want to report a security issue, please see https://matrix.org/security-disclosure-policy/ If you want to report a security issue, please see https://element.io/security/security-disclosure-policy
This is a bug report form. By following the instructions below and completing the sections with your information, you will help the us to get all the necessary data to fix your issue. This is a bug report form. By following the instructions below and completing the sections with your information, you will help the us to get all the necessary data to fix your issue.
...@@ -74,6 +74,36 @@ body: ...@@ -74,6 +74,36 @@ body:
- Debian packages from packages.matrix.org - Debian packages from packages.matrix.org
- pip (from PyPI) - pip (from PyPI)
- Other (please mention below) - Other (please mention below)
- I don't know
validations:
required: true
- type: input
id: database
attributes:
label: Database
description: |
Are you using SQLite or PostgreSQL? What's the version of your database?
If PostgreSQL, please also answer the following:
- are you using a single PostgreSQL server
or [separate servers for `main` and `state`](https://element-hq.github.io/synapse/latest/usage/configuration/config_documentation.html#databases)?
- have you previously ported from SQLite using the Synapse "portdb" script?
- have you previously restored from a backup?
validations:
required: true
- type: dropdown
id: workers
attributes:
label: Workers
description: |
Are you running a single Synapse process, or are you running
[2 or more workers](https://element-hq.github.io/synapse/latest/workers.html)?
options:
- Single process
- Multiple workers
- I don't know
validations:
required: true
- type: textarea - type: textarea
id: platform id: platform
attributes: attributes:
...@@ -83,17 +113,28 @@ body: ...@@ -83,17 +113,28 @@ body:
e.g. distro, hardware, if it's running in a vm/container, etc. e.g. distro, hardware, if it's running in a vm/container, etc.
validations: validations:
required: true required: true
- type: textarea
id: config
attributes:
label: Configuration
description: |
Do you have any unusual config options turned on? If so, please provide details.
- Experimental or undocumented features
- [Presence](https://element-hq.github.io/synapse/latest/usage/configuration/config_documentation.html#presence)
- [Message retention](https://element-hq.github.io/synapse/latest/message_retention_policies.html)
- [Synapse modules](https://element-hq.github.io/synapse/latest/modules/index.html)
- type: textarea - type: textarea
id: logs id: logs
attributes: attributes:
label: Relevant log output label: Relevant log output
description: | description: |
Please copy and paste any relevant log output, ideally at INFO or DEBUG log level. Please copy and paste any relevant log output as text (not images), ideally at INFO or DEBUG log level.
This will be automatically formatted into code, so there is no need for backticks. This will be automatically formatted into code, so there is no need for backticks (`\``).
Please be careful to remove any personal or private data. Please be careful to remove any personal or private data.
**Bug reports are usually very difficult to diagnose without logging.** **Bug reports are usually impossible to diagnose without logging.**
render: shell render: shell
validations: validations:
required: true required: true
......
### Pull Request Checklist ### Pull Request Checklist
<!-- Please read https://matrix-org.github.io/synapse/latest/development/contributing_guide.html before submitting your pull request --> <!-- Please read https://element-hq.github.io/synapse/latest/development/contributing_guide.html before submitting your pull request -->
* [ ] Pull request is based on the develop branch * [ ] Pull request is based on the develop branch
* [ ] Pull request includes a [changelog file](https://matrix-org.github.io/synapse/latest/development/contributing_guide.html#changelog). The entry should: * [ ] Pull request includes a [changelog file](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#changelog). The entry should:
- Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from `EventStore` to `EventWorkerStore`.". - Be a short description of your change which makes sense to users. "Fixed a bug that prevented receiving messages from other servers." instead of "Moved X method from `EventStore` to `EventWorkerStore`.".
- Use markdown where necessary, mostly for `code blocks`. - Use markdown where necessary, mostly for `code blocks`.
- End with either a period (.) or an exclamation mark (!). - End with either a period (.) or an exclamation mark (!).
- Start with a capital letter. - Start with a capital letter.
- Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry. - Feel free to credit yourself, by adding a sentence "Contributed by @github_username." or "Contributed by [Your Name]." to the end of the entry.
* [ ] Pull request includes a [sign off](https://matrix-org.github.io/synapse/latest/development/contributing_guide.html#sign-off) * [ ] [Code style](https://element-hq.github.io/synapse/latest/code_style.html) is correct
* [ ] [Code style](https://matrix-org.github.io/synapse/latest/code_style.html) is correct (run the [linters](https://element-hq.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))
(run the [linters](https://matrix-org.github.io/synapse/latest/development/contributing_guide.html#run-the-linters))
...@@ -18,5 +18,6 @@ updates: ...@@ -18,5 +18,6 @@ updates:
- package-ecosystem: "cargo" - package-ecosystem: "cargo"
directory: "/" directory: "/"
versioning-strategy: "lockfile-only"
schedule: schedule:
interval: "weekly" interval: "weekly"
name: Write changelog for dependabot PR
on:
pull_request:
types:
- opened
- reopened # For debugging!
permissions:
# Needed to be able to push the commit. See
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#enable-auto-merge-on-a-pull-request
# for a similar example
contents: write
jobs:
add-changelog:
runs-on: 'ubuntu-latest'
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Write, commit and push changelog
run: |
echo "${{ github.event.pull_request.title }}." > "changelog.d/${{ github.event.pull_request.number }}".misc
git add changelog.d
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "GitHub Actions"
git commit -m "Changelog"
git push
shell: bash
# The `git push` above does not trigger CI on the dependabot PR.
#
# By default, workflows can't trigger other workflows when they're just using the
# default `GITHUB_TOKEN` access token. (This is intended to stop you from writing
# recursive workflow loops by accident, because that'll get very expensive very
# quickly.) Instead, you have to manually call out to another workflow, or else
# make your changes (i.e. the `git push` above) using a personal access token.
# See
# https://docs.github.com/en/actions/using-workflows/triggering-a-workflow#triggering-a-workflow-from-a-workflow
#
# I have tried and failed to find a way to trigger CI on the "merge ref" of the PR.
# See git commit history for previous attempts. If anyone desperately wants to try
# again in the future, make a matrix-bot account and use its access token to git push.
# THIS WORKFLOW HAS WRITE PERMISSIONS---do not add other jobs here unless they
# are sufficiently locked down to dependabot only as above.
...@@ -10,35 +10,58 @@ on: ...@@ -10,35 +10,58 @@ on:
permissions: permissions:
contents: read contents: read
packages: write
id-token: write # needed for signing the images with GitHub OIDC Token
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-22.04
steps: steps:
- name: Set up QEMU - name: Set up QEMU
id: qemu id: qemu
uses: docker/setup-qemu-action@v2 uses: docker/setup-qemu-action@v3
with: with:
platforms: arm64 platforms: arm64
- name: Set up Docker Buildx - name: Set up Docker Buildx
id: buildx id: buildx
uses: docker/setup-buildx-action@v2 uses: docker/setup-buildx-action@v3
- name: Inspect builder - name: Inspect builder
run: docker buildx inspect run: docker buildx inspect
- name: Install Cosign
uses: sigstore/cosign-installer@v3.8.1
- name: Checkout repository
uses: actions/checkout@v4
- name: Extract version from pyproject.toml
# Note: explicitly requesting bash will mean bash is invoked with `-eo pipefail`, see
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell
shell: bash
run: |
echo "SYNAPSE_VERSION=$(grep "^version" pyproject.toml | sed -E 's/version\s*=\s*["]([^"]*)["]/\1/')" >> $GITHUB_ENV
- name: Log in to DockerHub - name: Log in to DockerHub
uses: docker/login-action@v2 uses: docker/login-action@v3
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Calculate docker image tag - name: Calculate docker image tag
id: set-tag id: set-tag
uses: docker/metadata-action@master uses: docker/metadata-action@master
with: with:
images: matrixdotorg/synapse images: |
docker.io/matrixdotorg/synapse
ghcr.io/element-hq/synapse
flavor: | flavor: |
latest=false latest=false
tags: | tags: |
...@@ -48,10 +71,13 @@ jobs: ...@@ -48,10 +71,13 @@ jobs:
type=pep440,pattern={{raw}} type=pep440,pattern={{raw}}
- name: Build and push all platforms - name: Build and push all platforms
uses: docker/build-push-action@v3 id: build-and-push
uses: docker/build-push-action@v6
with: with:
push: true push: true
labels: "gitsha1=${{ github.sha }}" labels: |
gitsha1=${{ github.sha }}
org.opencontainers.image.version=${{ env.SYNAPSE_VERSION }}
tags: "${{ steps.set-tag.outputs.tags }}" tags: "${{ steps.set-tag.outputs.tags }}"
file: "docker/Dockerfile" file: "docker/Dockerfile"
platforms: linux/amd64,linux/arm64 platforms: linux/amd64,linux/arm64
...@@ -60,3 +86,14 @@ jobs: ...@@ -60,3 +86,14 @@ jobs:
# https://github.com/rust-lang/cargo/issues/10583 # https://github.com/rust-lang/cargo/issues/10583
build-args: | build-args: |
CARGO_NET_GIT_FETCH_WITH_CLI=true CARGO_NET_GIT_FETCH_WITH_CLI=true
- name: Sign the images with GitHub OIDC Token
env:
DIGEST: ${{ steps.build-and-push.outputs.digest }}
TAGS: ${{ steps.set-tag.outputs.tags }}
run: |
images=""
for tag in ${TAGS}; do
images+="${tag}@${DIGEST} "
done
cosign sign --yes ${images}
name: Deploy documentation PR preview
on:
workflow_run:
workflows: [ "Prepare documentation PR preview" ]
types:
- completed
jobs:
netlify:
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request'
runs-on: ubuntu-latest
steps:
# There's a 'download artifact' action, but it hasn't been updated for the workflow_run action
# (https://github.com/actions/download-artifact/issues/60) so instead we get this mess:
- name: 📥 Download artifact
uses: dawidd6/action-download-artifact@20319c5641d495c8a52e688b7dc5fada6c3a9fbc # v8
with:
workflow: docs-pr.yaml
run_id: ${{ github.event.workflow_run.id }}
name: book
path: book
- name: 📤 Deploy to Netlify
uses: matrix-org/netlify-pr-preview@v3
with:
path: book
owner: ${{ github.event.workflow_run.head_repository.owner.login }}
branch: ${{ github.event.workflow_run.head_branch }}
revision: ${{ github.event.workflow_run.head_sha }}
token: ${{ secrets.NETLIFY_AUTH_TOKEN }}
site_id: ${{ secrets.NETLIFY_SITE_ID }}
desc: Documentation preview
deployment_env: PR Documentation Preview