build and test pipelines #2

Merged
bizcochito merged 37 commits from build into develop 2024-02-23 07:14:21 +00:00
5 changed files with 849 additions and 544 deletions

View File

@ -32,3 +32,4 @@ LICENSE
README.md README.md
config.toml config.toml
mastodon-data.toml mastodon-data.toml
*.yaml

View File

@ -0,0 +1,22 @@
name: Unit Tests with docker compose and cargo
on: [push, pull_request]
jobs:
unit-test:
container:
image: docker:dind
volumes:
- /data/.cache/act:/data/.cache/act
- /var/lib/docker/image:/var/lib/docker/image
- /var/lib/docker/overlay2:/var/lib/docker/overlay2
steps:
- name: Starting docker daemon
run: docker-init -- dockerd --host=unix:///var/run/docker.sock &
- name: Installing necessary packages
run: apk add nodejs git curl bash
- name: Check out repository code
uses: actions/checkout@v3
- name: Get access token from secret
run: echo "${{ secrets.MASTODON_SECRET }}" > mastodon-data.toml
- name: Run tests on docker
run: docker compose down -v && docker compose run bot t

View File

@ -0,0 +1,52 @@
name: Build image
on:
push:
branches:
- main
- build
tags:
- v*
jobs:
build:
container:
image: docker:dind
volumes:
- /data/.cache/act:/data/.cache/act
- /var/lib/docker/image:/var/lib/docker/image
- /var/lib/docker/overlay2:/var/lib/docker/overlay2
steps:
- name: Starting docker daemon
run: docker-init -- dockerd --host=unix:///var/run/docker.sock &
- name: Installing necessary packages
run: apk add nodejs git curl bash
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: https://github.com/docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
git.fai.st/fedi-image-bot/mastodon-image-uploader-bot
# generate Docker tags based on the following events/attributes
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
type=ref,event=branch
type=semver,pattern={{raw}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to fai.st docker registry
uses: docker/login-action@v2
with:
registry: git.fai.st
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
- name: Build and push
uses: docker/build-push-action@v4
with:
platforms: linux/amd64,linux/arm64
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

1314
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,7 @@ ARG APP_NAME=mastodon-image-uploader-bot
FROM rust:${RUST_VERSION}-slim-bullseye AS build FROM rust:${RUST_VERSION}-slim-bullseye AS build
ARG APP_NAME ARG APP_NAME
WORKDIR /app WORKDIR /app
RUN apt update && apt install pkg-config openssl libssl-dev -y
# Build the application. # Build the application.
# Leverage a cache mount to /usr/local/cargo/registry/ # Leverage a cache mount to /usr/local/cargo/registry/
# for downloaded dependencies and a cache mount to /app/target/ for # for downloaded dependencies and a cache mount to /app/target/ for
@ -23,8 +23,6 @@ WORKDIR /app
RUN --mount=type=bind,source=src,target=src \ RUN --mount=type=bind,source=src,target=src \
--mount=type=bind,source=Cargo.toml,target=Cargo.toml \ --mount=type=bind,source=Cargo.toml,target=Cargo.toml \
--mount=type=bind,source=Cargo.lock,target=Cargo.lock \ --mount=type=bind,source=Cargo.lock,target=Cargo.lock \
--mount=type=cache,target=/app/target/ \
--mount=type=cache,target=/usr/local/cargo/registry/ \
<<EOF <<EOF
set -e set -e
cargo build --locked --release cargo build --locked --release