[ci] Improve performance
This commit is contained in:
parent
53cd66e754
commit
e4089d3e82
9 changed files with 130 additions and 169 deletions
11
.forgejo/ci-env-wasm/Dockerfile
Normal file
11
.forgejo/ci-env-wasm/Dockerfile
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:8.0
|
||||||
|
RUN apt-get update && apt-get install git bash python3 curl golang nodejs zstd ca-certificates -y
|
||||||
|
RUN install -m 0755 -d /etc/apt/keyrings
|
||||||
|
RUN curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
|
||||||
|
RUN chmod a+r /etc/apt/keyrings/docker.asc
|
||||||
|
RUN echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||||
|
RUN apt-get update && apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin -y
|
||||||
|
RUN curl -o /bin/git-restore-mtime https://raw.githubusercontent.com/MestreLion/git-tools/main/git-restore-mtime
|
||||||
|
RUN chmod +x /bin/git-restore-mtime
|
||||||
|
RUN dotnet workload install wasm-tools
|
||||||
|
CMD ["/bin/sh"]
|
5
.forgejo/ci-env/Dockerfile
Normal file
5
.forgejo/ci-env/Dockerfile
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine
|
||||||
|
RUN apk add --no-cache --no-progress git docker bash python3 curl go nodejs-current zstd
|
||||||
|
RUN curl -o /bin/git-restore-mtime https://raw.githubusercontent.com/MestreLion/git-tools/main/git-restore-mtime
|
||||||
|
RUN chmod +x /bin/git-restore-mtime
|
||||||
|
CMD ["/bin/sh"]
|
6
.forgejo/ci-release/Dockerfile
Normal file
6
.forgejo/ci-release/Dockerfile
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy-chiseled AS image-aot
|
||||||
|
ARG TARGETARCH
|
||||||
|
WORKDIR /app
|
||||||
|
COPY linux-$TARGETARCH/ .
|
||||||
|
USER app
|
||||||
|
ENTRYPOINT ["./Iceshrimp.Backend", "--environment", "Production", "--migrate-and-start"]
|
|
@ -1,62 +0,0 @@
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- 'dev'
|
|
||||||
jobs:
|
|
||||||
unit-tests:
|
|
||||||
runs-on: docker
|
|
||||||
container:
|
|
||||||
image: mcr.microsoft.com/dotnet/sdk:8.0-alpine
|
|
||||||
options: --volume /opt/iceshrimp-cache/nuget:/root/.nuget
|
|
||||||
steps:
|
|
||||||
- name: Clone repository
|
|
||||||
run: git clone ${{ github.event.repository.clone_url }} --branch=${{ github.ref_name }} --depth=1 /iceshrimp
|
|
||||||
- name: Run unit tests
|
|
||||||
run: |
|
|
||||||
cd /iceshrimp
|
|
||||||
dotnet test
|
|
||||||
build-and-push:
|
|
||||||
needs:
|
|
||||||
- unit-tests
|
|
||||||
runs-on: docker
|
|
||||||
container:
|
|
||||||
image: node:16-bullseye
|
|
||||||
options: --volume /opt/iceshrimp-cache/rewrite:/buildkit-cache
|
|
||||||
permissions:
|
|
||||||
packages: write
|
|
||||||
steps:
|
|
||||||
- name: Clone repository
|
|
||||||
run: git clone ${{ github.event.repository.clone_url }} --branch=${{ github.ref_name }} --depth=1 /iceshrimp
|
|
||||||
- name: Install Docker Cli
|
|
||||||
run: |-
|
|
||||||
install -m 0755 -d /etc/apt/keyrings
|
|
||||||
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
|
||||||
chmod a+r /etc/apt/keyrings/docker.gpg
|
|
||||||
echo \
|
|
||||||
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
|
|
||||||
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" > /etc/apt/sources.list.d/docker.list
|
|
||||||
apt-get -qq update
|
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -qq -y docker-ce-cli docker-buildx-plugin docker-compose-plugin
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: https://code.forgejo.org/docker/setup-buildx-action@v3
|
|
||||||
- name: Authenticate against the registry
|
|
||||||
uses: https://code.forgejo.org/docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: iceshrimp.dev
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
||||||
- name: Set environment variables
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
echo "REPO=${GITHUB_REPOSITORY@L}" >> "${GITHUB_ENV}"
|
|
||||||
- name: Build and push
|
|
||||||
uses: https://code.forgejo.org/docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: /iceshrimp
|
|
||||||
push: true
|
|
||||||
tags: iceshrimp.dev/${{ env.REPO }}:${{ github.ref_name }}
|
|
||||||
target: image-jit
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
provenance: false
|
|
||||||
cache-from: type=local,src=/buildkit-cache
|
|
||||||
cache-to: type=local,dest=/buildkit-cache
|
|
39
.forgejo/workflows/commit.yaml
Normal file
39
.forgejo/workflows/commit.yaml
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- 'dev'
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: iceshrimp.dev/iceshrimp/iceshrimp.net:ci-env
|
||||||
|
options: |
|
||||||
|
--volume /opt/iceshrimp-cache/nuget:/root/.nuget
|
||||||
|
--volume /root/.docker:/root/.docker
|
||||||
|
steps:
|
||||||
|
- name: Clone repository
|
||||||
|
run: |
|
||||||
|
git clone ${{ github.event.repository.clone_url }} --branch=${{ github.ref_name }} /iceshrimp
|
||||||
|
cd /iceshrimp
|
||||||
|
- name: Run unit tests
|
||||||
|
run: |
|
||||||
|
cd /iceshrimp
|
||||||
|
dotnet test
|
||||||
|
- name: Clean repo
|
||||||
|
run: |
|
||||||
|
cd /iceshrimp
|
||||||
|
git clean -xfd
|
||||||
|
- name: Authenticate against the docker registry
|
||||||
|
run: docker login iceshrimp.dev -u ${{ github.actor }} -p ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
- name: Initialize builder
|
||||||
|
run: docker buildx use iceshrimp-ci || docker buildx create --name iceshrimp-ci --use
|
||||||
|
- name: Patch Dockerfile
|
||||||
|
run: |
|
||||||
|
sed -i 's^mcr.microsoft.com/dotnet/sdk:8.0-alpine^iceshrimp.dev/iceshrimp/iceshrimp.net:ci-env^g' /iceshrimp/Dockerfile
|
||||||
|
sed -i 's^mcr.microsoft.com/dotnet/sdk:8.0^iceshrimp.dev/iceshrimp/iceshrimp.net:ci-env-wasm^g' /iceshrimp/Dockerfile
|
||||||
|
sed -i 's^dotnet workload install wasm-tools^echo^g' /iceshrimp/Dockerfile
|
||||||
|
- name: Build the image
|
||||||
|
shell: bash
|
||||||
|
run: docker buildx build --target image-jit -t iceshrimp.dev/${GITHUB_REPOSITORY@L}:$GITHUB_REF_NAME --provenance=false --platform=linux/amd64,linux/arm64 --push /iceshrimp
|
||||||
|
- name: Purge cache
|
||||||
|
run: docker buildx prune --keep-storage 10G
|
68
.forgejo/workflows/release-artifacts.yaml
Normal file
68
.forgejo/workflows/release-artifacts.yaml
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
on:
|
||||||
|
release:
|
||||||
|
types:
|
||||||
|
- published
|
||||||
|
jobs:
|
||||||
|
build-artifacts:
|
||||||
|
runs-on: docker
|
||||||
|
container:
|
||||||
|
image: iceshrimp.dev/iceshrimp/iceshrimp.net:ci-env-wasm
|
||||||
|
options: --volume /opt/iceshrimp-cache/nuget:/root/.nuget
|
||||||
|
steps:
|
||||||
|
- name: Clone repository
|
||||||
|
run: git clone ${{ github.event.repository.clone_url }} --branch=${{ github.ref_name }} /src
|
||||||
|
- name: Build project (amd64)
|
||||||
|
shell: bash
|
||||||
|
run: |-
|
||||||
|
cd /src/Iceshrimp.Backend
|
||||||
|
mkdir -p /out/linux-amd64
|
||||||
|
dotnet publish -c Release -p:EnableAOT=true -p:EnableLibVips=true -p:BundleNativeDeps=true -r linux-amd64 -o /out/linux-amd64
|
||||||
|
- name: Build project (arm64)
|
||||||
|
shell: bash
|
||||||
|
run: |-
|
||||||
|
cd /src/Iceshrimp.Backend
|
||||||
|
mkdir -p /out/linux-arm64
|
||||||
|
dotnet publish -c Release -p:EnableAOT=true -p:EnableLibVips=true -p:BundleNativeDeps=true -r linux-arm64 -o /out/linux-arm64
|
||||||
|
- name: Generate artifacts
|
||||||
|
shell: bash
|
||||||
|
run: |-
|
||||||
|
mkdir artifacts
|
||||||
|
tar cavf artifacts/${{ github.event.repository.name }}-${{ github.ref_name }}-linux-amd64.tar.zst --transform 's,^out/linux-amd64,${{ github.event.repository.name }}-${{ github.ref_name }},' /out/linux-amd64
|
||||||
|
tar cavf artifacts/${{ github.event.repository.name }}-${{ github.ref_name }}-linux-arm64.tar.zst --transform 's,^out/linux-arm64,${{ github.event.repository.name }}-${{ github.ref_name }},' /out/linux-arm64
|
||||||
|
- name: Upload artifacts
|
||||||
|
uses: actions/release-action@main
|
||||||
|
with:
|
||||||
|
files: |-
|
||||||
|
artifacts/**
|
||||||
|
api_key: '${{secrets.RELEASE_TOKEN}}'
|
||||||
|
- name: Authenticate against the docker registry
|
||||||
|
run: docker login iceshrimp.dev -u ${{ github.actor }} -p ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
- name: Initialize builder
|
||||||
|
run: docker buildx use iceshrimp-ci || docker buildx create --name iceshrimp-ci --use
|
||||||
|
- name: Set environment variables
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
# First, we set the docker repository we want to push to
|
||||||
|
REPO="iceshrimp.dev/${GITHUB_REPOSITORY@L}"
|
||||||
|
|
||||||
|
# We always want to tag :{version} and :pre, but only tag :latest for stable releases, and (temporarily) v2024.1-beta releases
|
||||||
|
TAGS="-t $REPO:$GITHUB_REF_NAME -t $REPO:pre"
|
||||||
|
|
||||||
|
# The first section below can be safely removed once v2024.1 hits stable
|
||||||
|
if [[ "$GITHUB_REF_NAME" == "v2024.1-beta"* ]]; then
|
||||||
|
TAGS="$TAGS -t $REPO:latest"
|
||||||
|
elif [[ "$GITHUB_REF_NAME" == *"-beta"* ]] || [[ "$GITHUB_REF_NAME" == *"-pre"* ]]; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
TAGS="$TAGS -t $REPO:latest"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Finally, we pass the computed tags back to the actions environment
|
||||||
|
echo "TAGS=$TAGS" >> "${GITHUB_ENV}"
|
||||||
|
- name: Build the image
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cp /src/.forgejo/ci-release/Dockerfile /out
|
||||||
|
docker buildx build ${{ env.TAGS }} --provenance=false --platform=linux/amd64,linux/arm64 --push /out
|
||||||
|
- name: Purge cache
|
||||||
|
run: docker buildx prune --keep-storage 10G
|
|
@ -1,64 +0,0 @@
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- '*'
|
|
||||||
jobs:
|
|
||||||
build-and-push:
|
|
||||||
runs-on: docker
|
|
||||||
container:
|
|
||||||
image: node:16-bullseye
|
|
||||||
options: --volume /opt/iceshrimp-cache/rewrite:/buildkit-cache
|
|
||||||
permissions:
|
|
||||||
packages: write
|
|
||||||
steps:
|
|
||||||
- name: Clone repository
|
|
||||||
run: git clone ${{ github.event.repository.clone_url }} --branch=${{ github.ref_name }} --depth=1 /iceshrimp
|
|
||||||
- name: Install Docker Cli
|
|
||||||
run: |-
|
|
||||||
install -m 0755 -d /etc/apt/keyrings
|
|
||||||
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
|
||||||
chmod a+r /etc/apt/keyrings/docker.gpg
|
|
||||||
echo \
|
|
||||||
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
|
|
||||||
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" > /etc/apt/sources.list.d/docker.list
|
|
||||||
apt-get -qq update
|
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -qq -y docker-ce-cli docker-buildx-plugin docker-compose-plugin
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: https://code.forgejo.org/docker/setup-buildx-action@v3
|
|
||||||
- name: Authenticate against the registry
|
|
||||||
uses: https://code.forgejo.org/docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: iceshrimp.dev
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
||||||
- name: Set environment variables
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
# First, we set the docker repository we want to push to
|
|
||||||
REPO="iceshrimp.dev/${GITHUB_REPOSITORY@L}"
|
|
||||||
|
|
||||||
# We always want to tag :{version} and :pre, but only tag :latest for stable releases, and (temporarily) v2024.1-beta releases
|
|
||||||
TAGS="$REPO:$GITHUB_REF_NAME,$REPO:pre"
|
|
||||||
|
|
||||||
# The first section below can be safely removed once v2024.1 hits stable
|
|
||||||
if [[ "$GITHUB_REF_NAME" == "v2024.1-beta"* ]]; then
|
|
||||||
TAGS="$TAGS,$REPO:latest"
|
|
||||||
elif [[ "$GITHUB_REF_NAME" == *"-beta"* ]] || [[ "$GITHUB_REF_NAME" == *"-pre"* ]]; then
|
|
||||||
:
|
|
||||||
else
|
|
||||||
TAGS="$TAGS,$REPO:latest"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Finally, we pass the computed tags back to the actions environment
|
|
||||||
echo "TAGS=$TAGS" >> "${GITHUB_ENV}"
|
|
||||||
- name: Build and push
|
|
||||||
uses: https://code.forgejo.org/docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: /iceshrimp
|
|
||||||
push: true
|
|
||||||
tags: ${{ env.TAGS }}
|
|
||||||
target: image-aot
|
|
||||||
platforms: linux/amd64,linux/arm64
|
|
||||||
provenance: false
|
|
||||||
cache-from: type=local,src=/buildkit-cache
|
|
||||||
cache-to: type=local,dest=/buildkit-cache
|
|
|
@ -1,42 +0,0 @@
|
||||||
on:
|
|
||||||
release:
|
|
||||||
types:
|
|
||||||
- published
|
|
||||||
jobs:
|
|
||||||
build-artifacts:
|
|
||||||
runs-on: docker
|
|
||||||
container:
|
|
||||||
image: mcr.microsoft.com/dotnet/sdk:8.0-bookworm-slim
|
|
||||||
options: --volume /opt/iceshrimp-cache/nuget:/root/.nuget
|
|
||||||
permissions:
|
|
||||||
releases: write
|
|
||||||
steps:
|
|
||||||
- name: Prepare actions environment
|
|
||||||
run: |-
|
|
||||||
apt-get update && apt-get install nodejs zstd python3 -y
|
|
||||||
dotnet workload install wasm-tools
|
|
||||||
- name: Clone repository
|
|
||||||
run: git clone ${{ github.event.repository.clone_url }} --branch=${{ github.ref_name }} --depth=1 /src
|
|
||||||
- name: Setup go
|
|
||||||
uses: actions/setup-go@main
|
|
||||||
with:
|
|
||||||
go-version: '>=1.20.1'
|
|
||||||
- name: Build project
|
|
||||||
shell: bash
|
|
||||||
run: |-
|
|
||||||
cd /src/Iceshrimp.Backend
|
|
||||||
mkdir -p /out/{linux-x64,linux-arm64}
|
|
||||||
dotnet publish -c Release -p:EnableAOT=true -p:BundleNativeDeps=true -r linux-x64 -o /out/linux-x64
|
|
||||||
dotnet publish -c Release -p:EnableAOT=true -p:BundleNativeDeps=true -r linux-arm64 -o /out/linux-arm64
|
|
||||||
- name: Generate artifacts
|
|
||||||
shell: bash
|
|
||||||
run: |-
|
|
||||||
mkdir artifacts
|
|
||||||
tar cavf artifacts/${{ github.event.repository.name }}-${{ github.ref_name }}-linux-amd64.tar.zst --transform 's,^out/linux-x64,${{ github.event.repository.name }}-${{ github.ref_name }},' /out/linux-x64
|
|
||||||
tar cavf artifacts/${{ github.event.repository.name }}-${{ github.ref_name }}-linux-arm64.tar.zst --transform 's,^out/linux-arm64,${{ github.event.repository.name }}-${{ github.ref_name }},' /out/linux-arm64
|
|
||||||
- name: Upload artifacts
|
|
||||||
uses: actions/release-action@main
|
|
||||||
with:
|
|
||||||
files: |-
|
|
||||||
artifacts/**
|
|
||||||
api_key: '${{secrets.RELEASE_TOKEN}}'
|
|
|
@ -7,7 +7,7 @@ jobs:
|
||||||
test-build:
|
test-build:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
container:
|
container:
|
||||||
image: mcr.microsoft.com/dotnet/sdk:8.0-alpine
|
image: iceshrimp.dev/iceshrimp/iceshrimp.net:ci-env
|
||||||
options: --volume /opt/iceshrimp-cache/nuget:/root/.nuget
|
options: --volume /opt/iceshrimp-cache/nuget:/root/.nuget
|
||||||
steps:
|
steps:
|
||||||
- name: Clone repository
|
- name: Clone repository
|
||||||
|
|
Loading…
Add table
Reference in a new issue