Skip to content

Commit 56d6f8e

Browse files
ci: Use new docker-supporting backend workflows
1 parent da345a4 commit 56d6f8e

File tree

4 files changed

+48
-108
lines changed

4 files changed

+48
-108
lines changed

.config/starte2e.sh

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,41 @@ set -eu
55
# CI does not add /usr/bin to $PATH for some reason, which means we
66
# lack docker
77
export PATH="${PATH}:/usr/bin"
8+
# Assume the default profile on older nextest versions
9+
NEXTEST_PROFILE="${NEXTEST_PROFILE:-default}"
10+
11+
# If we're running in CI, we are in a docker container, so containers
12+
# launched by us do not bind-mount into local directories. Instead, we
13+
# copy the test environment to the host, so that we can bind-mount
14+
# from there.
15+
16+
TEST_ENV="$(realpath "$(dirname "$0")/../tests/environment")"
17+
export ENV_PATH="$TEST_ENV"
18+
19+
if [ "$NEXTEST_PROFILE" = "ci" ]; then
20+
cp -r tests/environment "$RUNNER_TEMP/test-env"
21+
TEST_ENV="$RUNNER_TEMP/test-env"
22+
ENV_PATH="/home/runner/work/_temp/test-env"
23+
export ENV_PATH
24+
fi
825

926
# Make sure the containers can write some files that need to be shared
10-
touch tests/environment/zitadel/service-user.json
11-
chmod a+rw tests/environment/zitadel/service-user.json
27+
touch "$TEST_ENV/zitadel/service-user.json"
28+
chmod a+rw "$TEST_ENV/zitadel/service-user.json"
1229

1330
# We only take down ldap if the certs are too old and need regeneration
1431
ldap_down=""
15-
file_creation=$(date -r ./tests/environment/certs/ca.crt +%s || echo 0)
32+
file_creation=$(date -r "$TEST_ENV/certs/ca.crt" +%s || echo 0)
1633
if [ $(($(date +%s) - file_creation)) -gt $((25 * 24 * 60 * 60)) ]; then
1734
ldap_down="-v ldap"
1835
fi
1936

2037
# Shut down any still running test-setup first
21-
docker compose --project-directory ./tests/environment down -v test-setup "$ldap_down" || true
22-
docker compose --project-directory ./tests/environment up --wait \
23-
|| (docker compose --project-directory ./tests/environment logs test-setup; exit 1)
38+
docker compose --project-directory "$TEST_ENV" down -v test-setup "$ldap_down" || true
39+
docker compose --project-directory "$TEST_ENV" up --wait || (
40+
docker compose --project-directory "$TEST_ENV" logs test-setup
41+
exit 1
42+
)
43+
44+
echo "TEST_ENV=$TEST_ENV" >> "$NEXTEST_ENV"
45+
cat "$NEXTEST_ENV"

.github/workflows/rust-workflow.yml

Lines changed: 2 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -8,101 +8,13 @@ on:
88
pull_request:
99
branches: [ "*" ]
1010

11-
env:
12-
CARGO_TERM_COLOR: always
13-
1411
# Make sure there is no pipeline running uselessly.
1512
concurrency:
1613
group: ${{ github.workflow }}-${{ github.ref }}
1714
cancel-in-progress: true
1815

1916
# Defined CI jobs.
2017
jobs:
21-
simple-checks:
22-
container: docker-oss.nexus.famedly.de/rust-container:nightly
23-
runs-on: ubuntu-latest
24-
steps:
25-
- name: Checkout current repository
26-
uses: actions/checkout@v4
27-
28-
- uses: famedly/backend-build-workflows/.github/actions/rust-prepare@main
29-
with:
30-
gitlab_ssh: ${{ secrets.CI_SSH_PRIVATE_KEY}}
31-
gitlab_user: ${{ secrets.GITLAB_USER }}
32-
gitlab_pass: ${{ secrets.GITLAB_PASS }}
33-
34-
- name: Caching
35-
uses: Swatinem/rust-cache@68b3cb7503c78e67dae8373749990a220eb65352
36-
with:
37-
cache-on-failure: true
38-
cache-all-crates: true
39-
40-
- name: Rustfmt
41-
shell: bash
42-
run: cargo +${NIGHTLY_VERSION} fmt -- --check
43-
44-
- name: Clippy
45-
shell: bash
46-
run: cargo +${NIGHTLY_VERSION} clippy --workspace --all-targets -- -D warnings
47-
48-
- name: Doc-test
49-
shell: bash
50-
run: cargo +${NIGHTLY_VERSION} test --doc --workspace --verbose
51-
52-
- name: Udeps
53-
shell: bash
54-
run: cargo +${NIGHTLY_VERSION} udeps
55-
56-
- name: Typos
57-
shell: bash
58-
run: typos --exclude '*.key' --exclude '*.crt' --exclude '*.csr' --exclude '*.srl'
59-
6018
tests:
61-
runs-on: ubuntu-latest
62-
steps:
63-
- name: Checkout current repository
64-
uses: actions/checkout@v4
65-
66-
- uses: famedly/backend-build-workflows/.github/actions/rust-prepare@main
67-
with:
68-
gitlab_ssh: ${{ secrets.CI_SSH_PRIVATE_KEY}}
69-
gitlab_user: ${{ secrets.GITLAB_USER }}
70-
gitlab_pass: ${{ secrets.GITLAB_PASS }}
71-
72-
- name: Add llvm-tools rust component
73-
run: rustup component add llvm-tools-preview --toolchain stable-x86_64-unknown-linux-gnu
74-
75-
- name: Caching
76-
uses: Swatinem/rust-cache@68b3cb7503c78e67dae8373749990a220eb65352
77-
with:
78-
cache-on-failure: true
79-
cache-all-crates: true
80-
81-
- name: Install additional cargo tooling
82-
shell: bash
83-
run: cargo install cargo-nextest cargo-llvm-cov --locked
84-
85-
- name: Test
86-
timeout-minutes: 20
87-
shell: bash
88-
run: |
89-
docker compose --project-directory ./tests/environment down -v
90-
cargo llvm-cov nextest --profile ci --workspace --lcov --output-path lcov.info
91-
92-
- name: Get docker logs on failure
93-
shell: bash
94-
if: failure()
95-
run: |
96-
docker compose --project-directory ./tests/environment logs
97-
98-
- name: Codecov - Upload coverage
99-
uses: codecov/codecov-action@v4
100-
with:
101-
token: ${{secrets.CODECOV_TOKEN}}
102-
files: lcov.info
103-
104-
- name: Codecov - Upload test results
105-
uses: codecov/test-results-action@v1
106-
with:
107-
token: ${{secrets.CODECOV_TOKEN}}
108-
19+
uses: famedly/backend-build-workflows/.github/workflows/rust-workflow.yml@ccb800fdb716ff3b8459f19bb9ceb56544d0798e
20+
secrets: inherit

tests/e2e.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
#![cfg(test)]
44
/// E2E integration tests
5-
use std::{collections::HashSet, path::Path, pin::pin, time::Duration};
5+
use std::{collections::HashSet, path::PathBuf, pin::pin, time::Duration};
66

77
use base64::{engine::general_purpose, Engine as _};
88
use famedly_sync::{
@@ -2060,13 +2060,15 @@ async fn cleanup_test_users(config: &Config) {
20602060

20612061
/// Get the module's test environment config
20622062
async fn ldap_config() -> &'static Config {
2063+
let config_dir = std::env::var("TEST_ENV").map(PathBuf::from).expect("Cannot find config dir");
2064+
20632065
CONFIG_WITH_LDAP
20642066
.get_or_init(|| async {
2065-
let mut config = Config::new(Path::new("tests/environment/config.yaml"))
2067+
let mut config = Config::new(&config_dir.join("config.yaml"))
20662068
.expect("failed to parse test env file");
20672069

20682070
config.sources.ldap = serde_yaml::from_slice(
2069-
&std::fs::read(Path::new("tests/environment/ldap-config.template.yaml"))
2071+
&std::fs::read(config_dir.join("ldap-config.template.yaml"))
20702072
.expect("failed to read ldap config file"),
20712073
)
20722074
.expect("failed to parse ldap config");
@@ -2078,13 +2080,15 @@ async fn ldap_config() -> &'static Config {
20782080

20792081
/// Get the module's test environment config
20802082
async fn ukt_config() -> &'static Config {
2083+
let config_dir = std::env::var("TEST_ENV").map(PathBuf::from).expect("Cannot find config dir");
2084+
20812085
CONFIG_WITH_UKT
20822086
.get_or_init(|| async {
2083-
let mut config = Config::new(Path::new("tests/environment/config.yaml"))
2087+
let mut config = Config::new(&config_dir.join("config.yaml"))
20842088
.expect("failed to parse test env file");
20852089

20862090
config.sources.ukt = serde_yaml::from_slice(
2087-
&std::fs::read(Path::new("tests/environment/ukt-config.template.yaml"))
2091+
&std::fs::read(config_dir.join("ukt-config.template.yaml"))
20882092
.expect("failed to read ukt config file"),
20892093
)
20902094
.expect("failed to parse ukt config");
@@ -2096,13 +2100,15 @@ async fn ukt_config() -> &'static Config {
20962100

20972101
/// Get the module's test environment config
20982102
async fn csv_config() -> &'static Config {
2103+
let config_dir = std::env::var("TEST_ENV").map(PathBuf::from).expect("Cannot find config dir");
2104+
20992105
CONFIG_WITH_CSV
21002106
.get_or_init(|| async {
2101-
let mut config = Config::new(Path::new("tests/environment/config.yaml"))
2107+
let mut config = Config::new(&config_dir.join("config.yaml"))
21022108
.expect("failed to parse test env file");
21032109

21042110
config.sources.csv = serde_yaml::from_slice(
2105-
&std::fs::read(Path::new("tests/environment/csv-config.template.yaml"))
2111+
&std::fs::read(config_dir.join("csv-config.template.yaml"))
21062112
.expect("failed to read csv config file"),
21072113
)
21082114
.expect("failed to parse csv config");

tests/environment/docker-compose.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ services:
33
image: alpine/openssl:3.3.2
44
volumes:
55
- type: bind
6-
source: ./certs
6+
source: ${ENV_PATH}/certs
77
target: /certs
88
entrypoint: /certs/generate-certs.sh
99

@@ -20,7 +20,7 @@ services:
2020
- LDAP_TLS_VERIFY_CLIENTS=try
2121
volumes:
2222
- type: bind
23-
source: ./certs
23+
source: ${ENV_PATH}/certs
2424
target: /certs
2525
read_only: true
2626
depends_on:
@@ -34,10 +34,10 @@ services:
3434
entrypoint: /environment/test-setup.sh
3535
volumes:
3636
- type: bind
37-
source: ./
37+
source: ${ENV_PATH}/
3838
target: /environment
3939
- type: bind
40-
source: ./config.template.yaml
40+
source: ${ENV_PATH}/config.template.yaml
4141
target: /config.template.yaml
4242
read_only: true
4343
healthcheck:
@@ -59,7 +59,7 @@ services:
5959
- 8080:8080
6060
volumes:
6161
- type: bind
62-
source: ./zitadel/
62+
source: ${ENV_PATH}/zitadel/
6363
target: /zitadel-config/
6464
depends_on:
6565
db:

0 commit comments

Comments
 (0)