Skip to content

Commit 7c825d1

Browse files
authored
initial release (#1)
hide the pain
1 parent f195a02 commit 7c825d1

19 files changed

+1523
-10
lines changed

.cargo/config.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# [target.aarch64-unknown-linux-gnu]
2+
# linker = "aarch64-linux-gnu-gcc"

.devcontainer/Invoke-PostCreateCommand.ps1

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

.devcontainer/devcontainer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@
4545
// "forwardPorts": [],
4646
// Use 'postCreateCommand' to run commands after the container is created.
4747
// "postCreateCommand": "rustc --version",
48-
"postCreateCommand": "pwsh ./.devcontainer/Invoke-PostCreateCommand.ps1",
49-
"postStartCommand": "./.devcontainer/postStartCommand.sh",
48+
"postCreateCommand": "sh . ./.devcontainer/postCreateCommand.sh",
49+
"postStartCommand": "sh . ./.devcontainer/postStartCommand.sh",
5050
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
5151
"remoteUser": "vscode",
5252
"features": {
53-
"docker-from-docker": "latest",
53+
"docker-in-docker": "latest",
5454
"powershell": "latest"
5555
}
5656
}

.devcontainer/postCreateCommand.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
echo "postCreateCommand.sh"
4+
echo "--------------------"
5+
6+
sudo chmod +x .devcontainer/postStartCommand.sh

.devcontainer/postStartCommand.sh

100644100755
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
#!/bin/sh
22

3+
echo "postStartCommand.sh"
4+
echo "-------------------"
5+
36
sudo apt-get update
47
sudo apt-get upgrade -y
58

69
rustup --version
7-
#rustup toolchain install nightly --component rust-analyzer-preview
8-
910
rustc --version
1011

1112
# alias cls="clear"

.dockerignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# first ignore everything
2+
*
3+
# explictly add exceptions for required files/paths
4+
!src/**
5+
!Cargo.toml
6+
!Cargo.lock

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* text=auto eol=lf
2+
*.{cmd,[cC][mM][dD]} text eol=crlf
3+
*.{bat,[bB][aA][tT]} text eol=crlf

.github/dependabot.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: cargo
4+
directory: /
5+
schedule:
6+
interval: weekly
7+
ignore:
8+
- dependency-name: something

.github/workflows/ci.yml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: ci
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches-ignore:
7+
- "preview/**"
8+
paths-ignore:
9+
# - .github
10+
# - .scripts
11+
# - .charts
12+
- LICENSE
13+
- README.md
14+
pull_request:
15+
branches: [main]
16+
types: [opened, synchronize, reopened]
17+
18+
env:
19+
IMAGE_NAME: multi-arch-container-rust
20+
21+
jobs:
22+
build_app:
23+
runs-on: ubuntu-latest
24+
outputs:
25+
SemVer: ${{ steps.gitversion.outputs.SemVer }}
26+
FullSemVer: ${{ steps.gitversion.outputs.FullSemVer }}
27+
28+
steps:
29+
- uses: actions/checkout@v3
30+
with:
31+
fetch-depth: 0
32+
33+
- name: gitversion
34+
shell: pwsh
35+
id: gitversion
36+
run: |
37+
dotnet tool update -g GitVersion.Tool
38+
$GitVersion = dotnet-gitversion ${{ github.workspace }} /nofetch | ConvertFrom-Json
39+
Write-Host "SemVer=$($GitVersion.SemVer)"
40+
echo "SemVer=$($GitVersion.SemVer)" >> $env:GITHUB_OUTPUT
41+
Write-Host "FullSemVer=$($GitVersion.FullSemVer)"
42+
echo "FullSemVer=$($GitVersion.FullSemVer)" >> $env:GITHUB_OUTPUT
43+
44+
- name: cargo fetch
45+
run: cargo fetch
46+
47+
- name: cargo build
48+
run: cargo build --release
49+
50+
#TODO: could run cargo test here, etc...
51+
52+
build_image:
53+
if: false #debug disable
54+
runs-on: ubuntu-latest
55+
needs: build_app
56+
57+
#https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/
58+
#https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
59+
permissions:
60+
packages: write #for pushing container image
61+
62+
env:
63+
REGISTRY: ghcr.io
64+
#REPOSITORY: Note: set dynamically, i.e. github.repository_owner+IMAGE_NAME
65+
GIT_REPO: ${{ github.repository }}
66+
GIT_TAG: ${{ needs.build_app.outputs.SemVer }}
67+
GIT_BRANCH: ${{ github.ref }}
68+
GIT_COMMIT: ${{ github.sha }}
69+
70+
steps:
71+
72+
- uses: actions/checkout@v3
73+
with:
74+
fetch-depth: 0
75+
76+
- name: set vars (1 of 2)
77+
run: echo "REPOSITORY=${{ github.repository_owner }}/$IMAGE_NAME" >> $GITHUB_ENV
78+
79+
- name: set vars (2 of 2)
80+
if: github.ref != 'refs/heads/main' #non-default branch has a more verbose SemVer which we overwrite
81+
run: echo "GIT_TAG=dev" >> $GITHUB_ENV
82+
83+
- name: image:base
84+
run: docker build --platform linux/amd64 -t image:base . --target base
85+
if: false #debug
86+
87+
- name: image:dependencies
88+
run: docker build --platform linux/amd64 -t image:dependencies . --target dependencies
89+
if: false #debug
90+
91+
- name: image:source
92+
run: docker build --platform linux/amd64 -t image:source . --target source
93+
if: false #debug
94+
95+
- name: image:build
96+
run: docker build --platform linux/amd64 -t image:build . --target build
97+
if: false #debug
98+
99+
- name: image:final
100+
run: docker build --platform linux/amd64 -t image:final . --target final
101+
if: false #debug
102+
103+
- name: cargo version
104+
run: cargo version
105+
if: false #debug
106+
107+
- name: cargo fmt
108+
run: docker run --rm --name fmt image:source cargo fmt --all --check
109+
#if: always()
110+
if: false #debug
111+
112+
- name: cargo clippy
113+
run: docker run --rm --name clippy image:source cargo clippy -- -D warnings
114+
#if: always()
115+
if: false #debug
116+
117+
# - name: cargo test
118+
# run: docker run --rm --name clippy image:build cargo test
119+
# if: always()
120+
121+
- name: docker login ${{ env.REGISTRY }}
122+
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login $REGISTRY -u ${{ github.actor }} --password-stdin
123+
124+
- name: docker buildx build
125+
run: |
126+
docker buildx create --name multiarchtest --use
127+
docker buildx build \
128+
-t $REGISTRY/$REPOSITORY:$GIT_TAG \
129+
-t $REGISTRY/$REPOSITORY:latest \
130+
--label "GITHUB_RUN_ID=${{ github.run_id }}" \
131+
--label "IMAGE_NAME=$IMAGE_NAME" \
132+
--build-arg GIT_REPO=$GIT_REPO \
133+
--build-arg GIT_TAG=$GIT_TAG \
134+
--build-arg GIT_BRANCH=$GIT_BRANCH \
135+
--build-arg GIT_COMMIT=$GIT_COMMIT \
136+
--build-arg GITHUB_WORKFLOW=${{ github.workflow }} \
137+
--build-arg GITHUB_RUN_ID=${{ github.run_id }} \
138+
--build-arg GITHUB_RUN_NUMBER=${{ github.run_number }} \
139+
--platform linux/amd64,linux/arm64,linux/arm/v7 \
140+
--pull \
141+
--push \
142+
.

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
!.vscode/extensions.json
1+
## ignore everything, then explictly add items.
2+
3+
.vs/*
24
.vscode/*
5+
!.vscode/extensions.json
36

47
# Generated by Cargo
58
# will have compiled files and executables

0 commit comments

Comments
 (0)