Skip to content

Commit

Permalink
v2: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PurpShell committed Nov 3, 2024
1 parent 6b2004a commit 3db589c
Show file tree
Hide file tree
Showing 118 changed files with 4,617 additions and 7,363 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.editorconfig
logs
.venv
start
config.yaml
registration.yaml
*.db
*.pickle
21 changes: 8 additions & 13 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
indent_style = tab
indent_size = 4
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4

[*.py]
max_line_length = 99
trim_trailing_whitespace = true
insert_final_newline = true

# Indentation override for all JSON/YAML files
[*.{json,yaml,yml}]
[*.{yaml,yml,sql}]
indent_style = space
indent_size = 2

[{.gitlab-ci.yml,.github/workflows/*.yml}]
indent_size = 2
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: Bug report
about: If something is definitely wrong in the bridge (rather than just a setup issue),
file a bug report. Remember to include relevant logs.
labels: bug

---

<!--
Remember to include relevant logs, the bridge version and any other details.
If you aren't sure what's needed, ask in the Matrix room rather than opening an
incomplete issue. Issues with insufficient detail will likely just be ignored.
-->
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
contact_links:
- name: Troubleshooting docs & FAQ
url: https://docs.mau.fi/bridges/general/troubleshooting.html
about: Check this first if you're having problems setting up the bridge.
- name: Support room
url: https://matrix.to/#/#linkedin-matrix:nevarro.space
about: For setup issues not answered by the troubleshooting docs, ask in the Matrix room.
6 changes: 6 additions & 0 deletions .github/ISSUE_TEMPLATE/enhancement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
name: Enhancement request
about: Submit a feature request or other suggestion
labels: enhancement

---
10 changes: 0 additions & 10 deletions .github/dependabot.yml

This file was deleted.

128 changes: 73 additions & 55 deletions .github/workflows/deploy.yaml → .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Lint, Build, and Deploy
name: Lint & Deploy

on:
push:
Expand All @@ -10,64 +10,96 @@ on:
- created

env:
PYTHON_VERSION: 3.11
BEEPER_BRIDGE_TYPE: linkedin
CI_REGISTRY_IMAGE: "${{ secrets.CI_REGISTRY }}/bridge/linkedin"
GHCR_REGISTRY: ghcr.io
GHCR_REGISTRY_IMAGE: "ghcr.io/${{ github.repository }}"
BINARY_NAME: linkedin-matrix


jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: isort/isort-action@master
with:
sortPaths: "./linkedin_matrix"
- uses: psf/black@stable
with:
src: "./linkedin_matrix"
version: "22.3.0"
- name: pre-commit
run: |
pip install pre-commit
pre-commit run -av trailing-whitespace
pre-commit run -av end-of-file-fixer
pre-commit run -av check-yaml
pre-commit run -av check-added-large-files
test:
name: Run the tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go-version: [ "1.22", "1.23.2" ]
name: Lint ${{ matrix.go-version == '1.23.2' && '(latest)' || '(old)' }}

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5

- name: Set up Go
uses: actions/setup-go@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
go-version: ${{ matrix.go-version }}
cache: true

- name: Install dependencies
run: |
pip install -r requirements.txt
pip install -r dev-requirements.txt
- name: Install libolm
run: sudo apt-get install libolm-dev libolm3

- name: Run pytest
- name: Install dependencies
run: |
pytest -vv
pytest -vv > pytest-coverage.txt
go install golang.org/x/tools/cmd/goimports@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
export PATH="$HOME/go/bin:$PATH"
- name: Comment coverage
uses: coroo/[email protected]
if: ${{ github.event_name == 'pull_request' && github.event.action == 'created' }}
- name: Run pre-commit
uses: pre-commit/[email protected]

build:
runs-on: ubuntu-latest
needs: lint
env:
GOPATH: ${{ github.workspace }}/.cache
GOCACHE: ${{ github.workspace }}/.cache/build
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.23.2"
cache: true

- name: Create cache directory
run: mkdir -p .cache

- name: Get Mautrix Version
id: mautrix_version
run: echo "MAUTRIX_VERSION=$(grep 'maunium.net/go/mautrix ' go.mod | awk '{ print $2 }')" >> $GITHUB_ENV

- name: Set LDFLAGS
run: |
echo "GO_LDFLAGS=-s -w -linkmode external -extldflags '-static' \
-X main.Tag=${{ github.ref_name }} -X main.Commit=${{ github.sha }} \
-X 'main.BuildTime=`date -Iseconds`' \
-X 'maunium.net/go/mautrix.GoModVersion=${{ env.MAUTRIX_VERSION }}'" >> $GITHUB_ENV
- name: Build binary
run: go build -ldflags "$GO_LDFLAGS" -o $BINARY_NAME ./cmd/$BINARY_NAME

- name: Generate SHA256 checksum
run: sha256sum $BINARY_NAME | tee $BINARY_NAME.sha256sum

- name: Upload binary artifact
uses: actions/upload-artifact@v3
with:
name: $BINARY_NAME
path: $BINARY_NAME
build-docker:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Checkout code
uses: actions/checkout@v4

- name: Download binary artifact
uses: actions/download-artifact@v3
with:
name: $BINARY_NAME
path: ./

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand Down Expand Up @@ -100,9 +132,7 @@ jobs:

deploy-docker:
runs-on: ubuntu-latest
needs:
- lint
- build-docker
needs: build-docker
if: github.ref == 'refs/heads/master'
steps:
- name: Login to Beeper Docker registry
Expand Down Expand Up @@ -138,18 +168,6 @@ jobs:
BEEPER_STAGING_ADMIN_NIGHTLY_PASS: "${{ secrets.BEEPER_STAGING_ADMIN_NIGHTLY_PASS }}"
BEEPER_PROD_ADMIN_NIGHTLY_PASS: "${{ secrets.BEEPER_PROD_ADMIN_NIGHTLY_PASS }}"

publish-pypi:
runs-on: ubuntu-latest
needs:
- lint
if: ${{ github.event_name == 'release' && github.event.action == 'created' }}
steps:
- uses: actions/checkout@v4
- name: Publish to pypi
uses: pypa/[email protected]
with:
password: ${{ secrets.PYPI_TOKEN }}

tag-docker-release:
runs-on: ubuntu-latest
needs:
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: 'Lock old issues'

on:
schedule:
- cron: '0 18 * * *'
workflow_dispatch:

permissions:
issues: write
# pull-requests: write
# discussions: write

concurrency:
group: lock-threads

jobs:
lock-stale:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v5
id: lock
with:
issue-inactive-days: 90
process-only: issues
- name: Log processed threads
run: |
if [ '${{ steps.lock.outputs.issues }}' ]; then
echo "Issues:" && echo '${{ steps.lock.outputs.issues }}' | jq -r '.[] | "https://github.com/\(.owner)/\(.repo)/issues/\(.issue_number)"'
fi
Loading

0 comments on commit 3db589c

Please sign in to comment.