Skip to content

Commit

Permalink
Merge pull request #1166 from digitalfabrik/1154-split-circleci-config
Browse files Browse the repository at this point in the history
1154 split circleci config
  • Loading branch information
ztefanie authored Oct 16, 2023
2 parents 66ea4d9 + d5bfc66 commit 9cc5cb4
Show file tree
Hide file tree
Showing 28 changed files with 1,182 additions and 547 deletions.
3 changes: 3 additions & 0 deletions .circleci/autogenerated_header.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### AUTO GENERATED. DO NOT MODIFY. ###
# This file should be auto generated by the files in the src folder.
# You can update it by running `yarn run circleci:update-config`.
1,144 changes: 597 additions & 547 deletions .circleci/config.yml

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions .circleci/src/@common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2.1

orbs:
gradle: circleci/[email protected]
browser-tools: circleci/[email protected]

parameters:
run_commit:
default: true
type: boolean
run_backend:
default: false
type: boolean
run_frontend:
default: false
type: boolean
28 changes: 28 additions & 0 deletions .circleci/src/commands/check-circleci-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
description: This command builds the circle config from the files in src and validates that it is up-to-date and valid.
steps:
- run:
name: Install CircleCI CLI
command: curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/master/install.sh | sudo bash
- run:
name: Build circle config
command: ./scripts/circleci-update-config.sh
- run: # Taken from https://github.com/roopakv/orbs/blob/master/src/commands/fail_if_dirty.yml
name: CircleCI config up to date
# language=bash
command: |
FILES_MODIFIED=""
setcommit () {
FILES_MODIFIED=$(git status -s | grep -i -E '.*circleci/config.yml')
}
setcommit || true
if [ -z "$FILES_MODIFIED" ]
then
echo "The CircleCI config is up to date."
exit 0;
else
echo "The CircleCI config is not up to date. You can update it by running `yarn run circleci:update-config`."
exit 1;
fi
- run:
name: Validate circle config
command: circleci config validate
5 changes: 5 additions & 0 deletions .circleci/src/commands/install-app-toolbelt.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
steps:
- setup-npm-global
- run:
name: Install app-toolbelt
command: npm install --unsafe-perm -g https://github.com/digitalfabrik/app-toolbelt/archive/refs/heads/main.tar.gz
6 changes: 6 additions & 0 deletions .circleci/src/commands/install-dart-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
steps:
- run:
name: Install Dart
command: |
curl -o dart.deb https://storage.googleapis.com/dart-archive/channels/stable/release/3.0.5/linux_packages/dart_3.0.5-1_amd64.deb
sudo dpkg -i dart.deb
6 changes: 6 additions & 0 deletions .circleci/src/commands/install-dart-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
steps:
- run:
name: Install Dart
command: |
brew tap dart-lang/dart
brew install dart
23 changes: 23 additions & 0 deletions .circleci/src/commands/install-fvm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
steps:
- run:
name: Install FVM
command: |
dart pub global activate fvm
echo 'export PATH=$HOME/.pub-cache/bin:$PATH' >> $BASH_ENV
- restore_cache:
keys:
- fvm-0-{{ checksum ".fvm/fvm_config.json" }}-{{ arch }}
- run:
name: Install Flutter
command: fvm install
- save_cache:
key: fvm-0-{{ checksum ".fvm/fvm_config.json" }}-{{ arch }}
paths:
- .fvm
- ~/fvm/
- run:
name: Show Flutter version
command: fvm flutter --version
- run:
name: Configure Flutter
command: fvm flutter config --no-analytics
13 changes: 13 additions & 0 deletions .circleci/src/commands/install-protobuf-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
steps:
- run:
name: Install protobuf from GitHub
command: |
curl -LO "https://github.com/protocolbuffers/protobuf/releases/download/v21.11/protoc-21.11-linux-x86_64.zip"
unzip protoc*.zip -d $HOME/.local
echo 'export PATH=$HOME/.local/bin:$PATH' >> $BASH_ENV
- run:
name: Install Flutter plugin
# Do not use the dart from fvm here for installing protoc_plugin.
# Else we might get a "Can't load Kernel binary: Invalid kernel binary format version" because the dart
# versions do not match.
command: dart pub global activate protoc_plugin
11 changes: 11 additions & 0 deletions .circleci/src/commands/install-protobuf-mac.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
steps:
- run:
name: Install protobuf
command: |
curl -LO "https://github.com/protocolbuffers/protobuf/releases/download/v21.11/protoc-21.11-osx-x86_64.zip"
unzip protoc*.zip -d $HOME/.local
echo 'export PATH=$HOME/.local/bin:$PATH' >> $BASH_ENV
- run:
name: Install Flutter plugin
# Use dart directly here. See comment in install-protobuf-linux
command: dart pub global activate protoc_plugin
7 changes: 7 additions & 0 deletions .circleci/src/commands/setup-npm-global.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
steps:
- run:
name: Setup npm
command: |
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:"$PATH"' >> "$BASH_ENV"
37 changes: 37 additions & 0 deletions .circleci/src/jobs/administration-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
docker:
- image: cimg/node:19.1.0
environment:
working_directory: ~/project/administration
steps:
- checkout:
path: ~/project
- restore_cache:
keys:
- v1-node-modules-{{ checksum "package.json" }}-{{checksum "package-lock.json" }}
- install-dart-linux
- install-protobuf-linux
- run:
name: Install node dependencies
command: "[ ! -d node_modules ] && npm ci --loglevel warn --yes || echo package.json and package-lock.json unchanged. Using cache."
- run: |
npm run generate-graphql
npm run generate-protobuf
- run:
name: Lint
command: npm run lint
- run:
name: Test
command: npm run test -- --maxWorkers=2
- run:
name: Build
command: npm run build
- save_cache:
paths:
- node_modules
key: v1-node-modules-{{ checksum "package.json" }}-{{checksum "package-lock.json" }}
- store_artifacts:
path: build
- persist_to_workspace:
root: ~/project
paths:
- administration/build
18 changes: 18 additions & 0 deletions .circleci/src/jobs/administration-pack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
docker:
- image: debian:11 # We deploy on debian -> pack on debian
working_directory: ~/project/administration
steps:
- checkout:
path: ~/project
- attach_workspace:
at: /tmp/workspace
- run: ~/project/scripts/pack_deb.sh -v "0.$CIRCLE_BUILD_NUM" -f /tmp/workspace/administration/build -d "Administration backend for the Ehrenamtskarte app" -n "eak-administration"
- run: |
mkdir -p /tmp/artifacts/debs
mv *.deb /tmp/artifacts/debs
- store_artifacts:
path: /tmp/artifacts
- persist_to_workspace:
root: /tmp/artifacts
paths:
- debs/*.deb
39 changes: 39 additions & 0 deletions .circleci/src/jobs/backend-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
environment:
_JAVA_OPTIONS: "-Xmx3g"
GRADLE_OPTS: "-Dorg.gradle.daemon=false -Dorg.gradle.workers.max=2"
docker:
- image: cimg/openjdk:17.0.6-node
working_directory: ~/project/backend
steps:
- checkout:
path: ~/project
- run: git submodule sync
- run: git submodule update --init
- restore_cache:
key: v2-gradle-wrapper-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
- restore_cache:
key: v2-gradle-cache-{{ checksum "build.gradle.kts" }}
- run:
name: Check that GraphQL scheme is stable
command: |
./gradlew run --args="graphql-export ../specs/backend-api.graphql"
git diff --exit-code
- run:
name: Test
command: |
./gradlew test
- run: ./gradlew build
- save_cache:
paths:
- .gradle/wrapper
key: v2-gradle-wrapper-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}
- save_cache:
paths:
- .gradle/caches
key: v2-gradle-cache-{{ checksum "build.gradle.kts" }}
- store_artifacts:
path: build/libs
- persist_to_workspace:
root: ~/project
paths:
- backend/build/distributions/*
36 changes: 36 additions & 0 deletions .circleci/src/jobs/backend-health-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
docker:
- image: cimg/base:2023.03
- image: postgis/postgis:13-3.0-alpine
environment:
- POSTGRES_DB=ehrenamtskarte
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
steps:
- checkout:
path: ~/project
- attach_workspace:
at: /tmp/workspace
- run:
name: Install Curl
command: |
sudo apt update
sudo apt install curl -y
- run:
name: Install ca-certificates-java # workaround for current issue: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1030129
command: sudo apt install ca-certificates-java
- run:
name: Install openjdk-17-jre-headless
command: sudo apt install openjdk-17-jre-headless -y
- run:
name: Install backend
command: sudo dpkg -i /tmp/workspace/debs/eak-backend*.deb
- run:
name: Run migrate
command: /opt/ehrenamtskarte/backend/bin/backend migrate
- run:
name: Start backend
command: /opt/ehrenamtskarte/backend/bin/backend execute
background: true
- run:
name: Check health
command: curl --retry 120 --retry-delay 1 --retry-all-errors http://0.0.0.0:8000/health
18 changes: 18 additions & 0 deletions .circleci/src/jobs/backend-pack.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
docker:
- image: debian:11 # We deploy on debian -> pack on debian
working_directory: ~/project/backend
steps:
- checkout:
path: ~/project
- attach_workspace:
at: /tmp/workspace
- run: ~/project/scripts/pack_deb.sh -v "0.$CIRCLE_BUILD_NUM" -t /tmp/workspace/backend/build/distributions/*.tar -s ~/project/scripts/eak-backend.service -d "Backend server for the Ehrenamtskarte app" -n "eak-backend" -c "openjdk-17-jre-headless"
- run: |
mkdir -p /tmp/artifacts/debs
mv *.deb /tmp/artifacts/debs
- store_artifacts:
path: /tmp/artifacts
- persist_to_workspace:
root: /tmp/artifacts
paths:
- debs/*.deb
35 changes: 35 additions & 0 deletions .circleci/src/jobs/check-frontend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
docker:
- image: cimg/node:19.1.0-browsers
resource_class: small
working_directory: ~/project/frontend
steps:
- checkout:
path: ~/project
- browser-tools/install-chrome
- install-dart-linux
- install-fvm
- install-app-toolbelt
- install-protobuf-linux
- run:
name: Install Flutter Packages
command: fvm flutter pub get --enforce-lockfile
- run:
name: Check Formatting
command: fvm dart format -l 120 -o none --set-exit-if-changed .
- run:
name: Build Runner
command: |
# Statically use "bayern" build config for analyzing here
fvm flutter pub run build_runner build --define "df_build_config=name=bayern"
- run:
name: Check Analyzer and Linting
command: |
fvm flutter analyze --fatal-infos --fatal-warnings
fvm flutter analyze pubs/df_build_config --fatal-infos --fatal-warnings
fvm flutter analyze pubs/df_protobuf --fatal-infos --fatal-warnings
- run:
name: Tests
command: |
fvm flutter test
fvm flutter test pubs/df_build_config
fvm flutter test pubs/df_protobuf
10 changes: 10 additions & 0 deletions .circleci/src/jobs/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
docker:
- image: cimg/node:19.1.0-browsers
resource_class: small
environment:
TOTAL_CPUS: 1 # For resource_class small
TZ: 'Europe/Berlin' # Should be removed in IGAPP-39
shell: /bin/bash -eo pipefail
steps:
- checkout
- check-circleci-config
25 changes: 25 additions & 0 deletions .circleci/src/jobs/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
docker:
- image: cimg/base:2022.09
parameters:
server:
enum:
- entitlementcard.tuerantuer.org
- entitlementcard-test.tuerantuer.org
type: enum
ssh-host-fingerprint:
enum:
- '|1|dkYQrdGB1QML0o+POL3QzAkBbek=|b4Tm0Ymh82UKyZPJfVKy4t+MFV8= ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIONuARu18Fktz+j4QosI+nRqgMnFOMgE7OZLuTOwgZ0k'
- '|1|iikuvSrIo3wkj+EqUgLRMsAq6yk=|r9bSjkawWFa94b45qE/se5Oio5k= ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIED3MwobbCs+ENMLXdyqlJb3bJ26TuIYt977TA3NrN66'
type: enum
steps:
- attach_workspace:
at: /tmp/workspace
- add_ssh_keys:
fingerprints:
- "a1:3f:a7:c3:ff:12:40:1d:85:de:a7:ab:12:3f:cc:05"
- run:
name: "SFTP upload"
command: |
echo "<< parameters.ssh-host-fingerprint >>" >> known_hosts
echo "Uploading: " /tmp/workspace/debs/*.deb
sftp -b - -o UserKnownHostsFile=known_hosts ci@<< parameters.server >>:/local-apt-repository/ \<<< "put -r /tmp/workspace/debs/*.deb"
Loading

0 comments on commit 9cc5cb4

Please sign in to comment.