Skip to content

Commit 9d4eab1

Browse files
committed
Merge #338: dev: upgrade containers
1f5351d dev: upgrade containers (Cameron Garnham) Pull request description: many copy-paste from torrust-tracker - intergration tests are disabled for now. ACKs for top commit: da2ce7: ACK 1f5351d Tree-SHA512: 0bde3200efcde1ee914608e8d5aed322b7f763dacd7757bf5d0bffd98b2b26470cec6fe2ee1a8831322f57090373891cb7bdf86410200960af258d04ab63cdc5
2 parents aec16e6 + 1f5351d commit 9d4eab1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2046
-538
lines changed

.github/workflows/container.yaml

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
name: Container
2+
3+
on:
4+
push:
5+
branches:
6+
- "develop"
7+
- "main"
8+
- "releases/**/*"
9+
pull_request:
10+
branches:
11+
- "develop"
12+
- "main"
13+
14+
env:
15+
CARGO_TERM_COLOR: always
16+
17+
jobs:
18+
test:
19+
name: Test (Docker)
20+
runs-on: ubuntu-latest
21+
22+
strategy:
23+
matrix:
24+
target: [debug, release]
25+
26+
steps:
27+
- id: setup
28+
name: Setup Toolchain
29+
uses: docker/setup-buildx-action@v3
30+
31+
- id: build
32+
name: Build
33+
uses: docker/build-push-action@v5
34+
with:
35+
file: ./Containerfile
36+
push: false
37+
load: true
38+
target: ${{ matrix.target }}
39+
tags: torrust-tracker:local
40+
cache-from: type=gha
41+
cache-to: type=gha
42+
43+
- id: inspect
44+
name: Inspect
45+
run: docker image inspect torrust-tracker:local
46+
47+
- id: checkout
48+
name: Checkout Repository
49+
uses: actions/checkout@v4
50+
51+
- id: compose
52+
name: Compose
53+
run: docker compose build
54+
55+
context:
56+
name: Context
57+
needs: test
58+
runs-on: ubuntu-latest
59+
60+
outputs:
61+
continue: ${{ steps.check.outputs.continue }}
62+
type: ${{ steps.check.outputs.type }}
63+
version: ${{ steps.check.outputs.version }}
64+
65+
steps:
66+
- id: check
67+
name: Check Context
68+
run: |
69+
if [[ "${{ github.repository }}" == "torrust/torrust-tracker" ]]; then
70+
if [[ "${{ github.event_name }}" == "push" ]]; then
71+
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
72+
73+
echo "type=development" >> $GITHUB_OUTPUT
74+
echo "continue=true" >> $GITHUB_OUTPUT
75+
echo "On \`main\` Branch, Type: \`development\`"
76+
77+
elif [[ "${{ github.ref }}" == "refs/heads/develop" ]]; then
78+
79+
echo "type=development" >> $GITHUB_OUTPUT
80+
echo "continue=true" >> $GITHUB_OUTPUT
81+
echo "On \`develop\` Branch, Type: \`development\`"
82+
83+
elif [[ $(echo "${{ github.ref }}" | grep -P '^(refs\/heads\/releases\/)(v)(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$') ]]; then
84+
85+
version=$(echo "${{ github.ref }}" | sed -n -E 's/^(refs\/heads\/releases\/)//p')
86+
echo "version=$version" >> $GITHUB_OUTPUT
87+
echo "type=release" >> $GITHUB_OUTPUT
88+
echo "continue=true" >> $GITHUB_OUTPUT
89+
echo "In \`releases/$version\` Branch, Type: \`release\`"
90+
91+
else
92+
echo "Not Correct Branch. Will Not Continue"
93+
fi
94+
else
95+
echo "Not a Push Event. Will Not Continue"
96+
fi
97+
else
98+
echo "On a Forked Repository. Will Not Continue"
99+
fi
100+
101+
publish_development:
102+
name: Publish (Development)
103+
environment: dockerhub-torrust
104+
needs: context
105+
if: needs.context.outputs.continue == 'true' && needs.context.outputs.type == 'development'
106+
runs-on: ubuntu-latest
107+
108+
steps:
109+
- id: meta
110+
name: Docker Meta
111+
uses: docker/metadata-action@v5
112+
with:
113+
images: |
114+
"${{ secrets.DOCKER_HUB_USERNAME }}/${{secrets.DOCKER_HUB_REPOSITORY_NAME }}"
115+
tags: |
116+
type=ref,event=branch
117+
118+
- id: login
119+
name: Login to Docker Hub
120+
uses: docker/login-action@v3
121+
with:
122+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
123+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
124+
125+
- id: setup
126+
name: Setup Toolchain
127+
uses: docker/setup-buildx-action@v3
128+
129+
- name: Build and push
130+
uses: docker/build-push-action@v5
131+
with:
132+
file: ./Containerfile
133+
push: true
134+
tags: ${{ steps.meta.outputs.tags }}
135+
labels: ${{ steps.meta.outputs.labels }}
136+
cache-from: type=gha
137+
cache-to: type=gha
138+
139+
publish_release:
140+
name: Publish (Release)
141+
environment: dockerhub-torrust
142+
needs: context
143+
if: needs.context.outputs.continue == 'true' && needs.context.outputs.type == 'release'
144+
runs-on: ubuntu-latest
145+
146+
steps:
147+
- id: meta
148+
name: Docker Meta
149+
uses: docker/metadata-action@v5
150+
with:
151+
images: |
152+
"${{ secrets.DOCKER_HUB_USERNAME }}/${{secrets.DOCKER_HUB_REPOSITORY_NAME }}"
153+
tags: |
154+
type=semver,value=${{ needs.context.outputs.version }},pattern={{raw}}
155+
type=semver,value=${{ needs.context.outputs.version }},pattern={{version}}
156+
type=semver,value=${{ needs.context.outputs.version }},pattern=v{{major}}
157+
type=semver,value=${{ needs.context.outputs.version }},pattern={{major}}.{{minor}}
158+
159+
- id: login
160+
name: Login to Docker Hub
161+
uses: docker/login-action@v3
162+
with:
163+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
164+
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
165+
166+
- id: setup
167+
name: Setup Toolchain
168+
uses: docker/setup-buildx-action@v3
169+
170+
- name: Build and push
171+
uses: docker/build-push-action@v5
172+
with:
173+
file: ./Containerfile
174+
push: true
175+
tags: ${{ steps.meta.outputs.tags }}
176+
labels: ${{ steps.meta.outputs.labels }}
177+
cache-from: type=gha
178+
cache-to: type=gha

.github/workflows/deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,5 @@ jobs:
5151
env:
5252
CARGO_REGISTRY_TOKEN: "${{ secrets.TORRUST_UPDATE_CARGO_REGISTRY_TOKEN }}"
5353
run: |
54+
cargo publish -p torrust-index-located-error
5455
cargo publish -p torrust-index

.github/workflows/publish_docker_image.yaml

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

.github/workflows/test_docker.yaml

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

.github/workflows/testing.yaml

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -132,29 +132,3 @@ jobs:
132132
- id: coverage
133133
name: Generate Coverage Report
134134
run: cargo llvm-cov nextest --tests --benches --examples --workspace --all-targets --all-features
135-
136-
integration:
137-
name: Integrations
138-
runs-on: ubuntu-latest
139-
140-
steps:
141-
- id: checkout
142-
name: Checkout Repository
143-
uses: actions/checkout@v4
144-
145-
- id: setup
146-
name: Setup Toolchain
147-
uses: dtolnay/rust-toolchain@stable
148-
149-
- id: cache
150-
name: Enable Job Cache
151-
uses: Swatinem/rust-cache@v2
152-
153-
# Temporary Cleaning to avoid Rust Compiler Bug
154-
- id: clean
155-
name: Make Build Clean
156-
run: cargo clean
157-
158-
- id: test
159-
name: Run Integration Tests
160-
run: ./docker/bin/e2e/run-e2e-tests.sh

0 commit comments

Comments
 (0)