Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enh: convert bot to rust #52

Merged
merged 4 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflows/bot-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Deploy Lambda
on:
push:
branches:
- main
paths:
- app/bot/**
- .github/workflows/lambda-deploy.yml

concurrency:
group: ghas-erfiume-lambda-deploy-${{ github.ref }}

jobs:
rust-ci:
permissions:
actions: read
security-events: write
contents: read
uses: notdodo/github-actions/.github/workflows/[email protected]
with:
working-directory: ./app/bot

lambda-deploy:
needs: rust-ci
name: Deploy Lambda
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
defaults:
run:
working-directory: ./app/bot
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
# v4.2.1
with:
fetch-depth: 0
- uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502
# v4.0.2
with:
role-to-assume: arn:aws:iam::841162699174:role/erfiume-oidc-write
aws-region: eu-west-1
retry-max-attempts: 2
- name: Cargo cache
uses: swatinem/rust-cache@82a92a6e8fbeee089604da2575dc567ae9ddeaab
# v2.7.5
with:
cache-on-failure: true
cache-all-crates: true
workspaces: ./app/bot
- name: Install Zig toolchain
uses: korandoru/setup-zig@v1
with:
zig-version: master
- name: Install Cargo Lambda
uses: jaxxstorm/[email protected]
with:
repo: cargo-lambda/cargo-lambda
platform: linux
arch: x86_64
- name: Build and deploy Lambda
run: |
cargo lambda build --release
cargo lambda deploy
10 changes: 1 addition & 9 deletions .github/workflows/pulumi-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,13 @@ on:
pull_request:
paths:
- pulumi/**
- app/**
- .github/workflows/pulumi-preview.yml

concurrency:
group: ghas-erfiume-pulumi-preview-${{ github.ref }}
cancel-in-progress: true

jobs:
python-ci-app:
uses: notdodo/github-actions/.github/workflows/[email protected]
with:
poetry-version: latest
python-version: 3.12
working-directory: "./app"

python-ci-pulumi:
uses: notdodo/github-actions/.github/workflows/[email protected]
with:
Expand All @@ -28,7 +20,7 @@ jobs:
pulumi-preview:
name: Pulumi Preview
runs-on: ubuntu-latest
needs: [python-ci-pulumi, python-ci-app]
needs: [python-ci-pulumi]
permissions:
contents: read
pull-requests: write
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/pulumi-up.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ on:
- main
paths:
- pulumi/**
- app/**
- .github/workflows/pulumi-up.yml

concurrency:
Expand Down
12 changes: 11 additions & 1 deletion .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,27 @@ on:
pull_request:
paths:
- app/fetcher/**
- app/bot/**
- .github/workflows/lambda-deploy.yml

concurrency:
group: ghas-erfiume-lambda-deploy-${{ github.ref }}

jobs:
rust-ci:
rust-ci-fetcher:
permissions:
actions: read
security-events: write
contents: read
uses: notdodo/github-actions/.github/workflows/[email protected]
with:
working-directory: ./app/fetcher

rust-ci-bot:
permissions:
actions: read
security-events: write
contents: read
uses: notdodo/github-actions/.github/workflows/[email protected]
with:
working-directory: ./app/bot
4 changes: 2 additions & 2 deletions app/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ build-layer-zip:
poetry install --only main --sync
cd ..; mkdir -p ./dist/lambda-layer/python
cd ..; cp -r -p ./app/.venv/lib ./dist/lambda-layer/python/
cd ../dist/lambda-layer/python; rm -rf .venv .mypy_cache .ruff_cache .env Makefile poetry.lock pyproject.toml standalone.py fetcher
cd ../dist/lambda-layer/python; rm -rf .venv .mypy_cache .ruff_cache .env Makefile poetry.lock pyproject.toml standalone.py fetcher bot
cd ../dist/lambda-layer/python; zip -q -r -D -X -9 -A ../../lambda-layer.zip ../

build-lambda-zip: build-layer-zip
cd ..; mkdir -p ./dist/lambda-package/
cd ..; cp -r -p ./app/ ./dist/lambda-package/
cd ../dist/lambda-package/; rm -rf .venv .mypy_cache .ruff_cache .env Makefile poetry.lock pyproject.toml standalone.py fetcher
cd ../dist/lambda-package/; rm -rf .venv .mypy_cache .ruff_cache .env Makefile poetry.lock pyproject.toml standalone.py fetcher bot
cd ../dist/lambda-package/; zip -q -r -D -X -9 -A ../lambda.zip .

format: ## Format repository code
Expand Down
1 change: 1 addition & 0 deletions app/bot/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
Loading