Skip to content

Commit 614a3b4

Browse files
authored
Merge pull request #17 from tubarao312/example-app
Example app + container publishing
2 parents b4d457e + 7e1ff58 commit 614a3b4

14 files changed

Lines changed: 129 additions & 52 deletions

File tree

.github/workflows/rust-test.yml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@ name: Cargo Build & Test
22

33
on:
44
push:
5+
branches: [ main ]
6+
tags: [ 'v*' ]
57
pull_request:
68

79
env:
810
CARGO_TERM_COLOR: always
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
913

1014
jobs:
1115
build_and_test:
@@ -19,4 +23,35 @@ jobs:
1923
- uses: actions/checkout@v4
2024
- run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }}
2125
- run: cargo build --verbose
22-
- run: cargo test --verbose
26+
- run: cargo test --verbose
27+
28+
docker:
29+
needs: build_and_test
30+
runs-on: ubuntu-latest
31+
permissions:
32+
contents: read
33+
packages: write
34+
35+
steps:
36+
- uses: actions/checkout@v4
37+
38+
- name: Log in to the Container registry
39+
uses: docker/login-action@v3
40+
with:
41+
registry: ${{ env.REGISTRY }}
42+
username: ${{ github.actor }}
43+
password: ${{ secrets.GITHUB_TOKEN }}
44+
45+
- name: Extract metadata for Docker
46+
id: meta
47+
uses: docker/metadata-action@v5
48+
with:
49+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
50+
51+
- name: Build and push Docker image
52+
uses: docker/build-push-action@v5
53+
with:
54+
context: .
55+
push: ${{ github.event_name != 'pull_request' }}
56+
tags: ${{ steps.meta.outputs.tags }}
57+
labels: ${{ steps.meta.outputs.labels }}

Dockerfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM rust:1.75-slim as builder
2+
WORKDIR /usr/src/app
3+
COPY . .
4+
RUN cargo build --release
5+
6+
FROM debian:bookworm-slim
7+
COPY --from=builder /usr/src/app/target/release/dependency-cascade /usr/local/bin/
8+
ENTRYPOINT ["dependency-cascade"]

example/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Example Explanation
2+
This example shows a simple project with three nodes: `example_app`, `example_lib`, and `example_test`.
3+
4+
- `example_app` depends on `example_lib`
5+
- `example_test` depends on `example_app`
6+
7+
Whenever the contents of `example_app` are changed, `example_test` will show up in `dependency-cascade query`.
8+
If the contents of `example_lib` are changed, both `example_app` and `example_test` will show up in `dependency-cascade query` because `example_test` depends on `example_app`.
9+
10+
This is a simple example, but in the real world, you might have a more complex project with many dependencies and many tests.
11+
12+
# Pipeline Examples
13+
14+
## Github Actions
15+
16+
## Gitlab Pipeline
17+
Help wanted!
18+
19+
## Jenkins Pipeline
20+
Help wanted!
21+
22+
## CircleCI
23+
Help wanted!
24+

example/app/dependencies.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[module]
2+
name = "example_app"
3+
4+
[dependencies]
5+
example_lib = { name = "example_lib" } # Our imaginary app uses the example_lib
6+
7+
[metadata]
8+
type = "app"
9+
language = "rust"
10+
you_can_do_anything_here = "literally anything"
11+
12+
[file_paths]
13+
include = [
14+
"src/**/*"
15+
]
16+
exclude = [
17+
"README.md"
18+
]

example/app/src/app_code.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello world!

example/lib/dependencies.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[module]
2+
name = "example_lib"
3+
4+
# Our imaginary library doesn't depent on anything - that's fine.
5+
6+
[metadata]
7+
type = "lib"
8+
language = "rust"
9+
you_can_do_anything_here = "literally anything"
10+
11+
[file_paths]
12+
include = [
13+
"src/**/*"
14+
]
15+
exclude = [
16+
"README.md"
17+
]

example/lib/src/lib_code.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello world!

example/test/dependencies.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[module]
2+
name = "example_test"
3+
4+
# Our imaginary test depends on the example_app because that's the only thing we're testing.
5+
# In the real world, we'd try to check which services the test is meant to touch and make
6+
# those the dependencies, so that this dependency would show up whenever on of those gets
7+
# touched.
8+
9+
[dependencies]
10+
example_app = { name = "example_app" }
11+
12+
[metadata]
13+
type = "test"
14+
language = "rust"
15+
you_can_do_anything_here = "literally anything"
16+
17+
[file_paths]
18+
include = [
19+
"src/**/*"
20+
]
21+
exclude = [
22+
"README.md"
23+
]

example/test/src/test_code.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Hello world!

test/test_end2end/dependencies.toml

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)