tangled
alpha
login
or
join now
pierrelf.com
/
grain
0
fork
atom
Rust implementation of OCI Distribution Spec with granular access control
0
fork
atom
overview
issues
9
pulls
pipelines
Remove .github configuration (migrated to tangled)
pierrelf.com
1 month ago
f8ff0681
8c59765f
1/1
build.yml
success
3m 35s
-204
3 changed files
expand all
collapse all
unified
split
.github
dependabot.yml
workflows
docker-publish.yml
rust.yml
-6
.github/dependabot.yml
···
1
1
-
version: 2
2
2
-
updates:
3
3
-
- package-ecosystem: "cargo"
4
4
-
directory: "/"
5
5
-
schedule:
6
6
-
interval: "weekly"
-66
.github/workflows/docker-publish.yml
···
1
1
-
name: Docker Build and Publish
2
2
-
3
3
-
on:
4
4
-
push:
5
5
-
branches:
6
6
-
- main
7
7
-
tags:
8
8
-
- 'v*'
9
9
-
pull_request:
10
10
-
branches:
11
11
-
- main
12
12
-
13
13
-
env:
14
14
-
REGISTRY: ghcr.io
15
15
-
IMAGE_NAME: ${{ github.repository }}
16
16
-
17
17
-
jobs:
18
18
-
build-and-push:
19
19
-
runs-on: ubuntu-latest
20
20
-
permissions:
21
21
-
contents: read
22
22
-
packages: write
23
23
-
24
24
-
steps:
25
25
-
- name: Checkout repository
26
26
-
uses: actions/checkout@v4
27
27
-
28
28
-
- name: Set up Docker Buildx
29
29
-
uses: docker/setup-buildx-action@v3
30
30
-
31
31
-
- name: Log in to Container Registry
32
32
-
if: github.event_name != 'pull_request'
33
33
-
uses: docker/login-action@v3
34
34
-
with:
35
35
-
registry: ${{ env.REGISTRY }}
36
36
-
username: ${{ github.actor }}
37
37
-
password: ${{ secrets.GITHUB_TOKEN }}
38
38
-
39
39
-
- name: Extract metadata
40
40
-
id: meta
41
41
-
uses: docker/metadata-action@v5
42
42
-
with:
43
43
-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
44
44
-
tags: |
45
45
-
type=ref,event=branch
46
46
-
type=ref,event=pr
47
47
-
type=semver,pattern={{version}}
48
48
-
type=semver,pattern={{major}}.{{minor}}
49
49
-
type=semver,pattern={{major}}
50
50
-
type=raw,value=latest,enable={{is_default_branch}}
51
51
-
52
52
-
- name: Build and push Docker image
53
53
-
id: build
54
54
-
uses: docker/build-push-action@v5
55
55
-
with:
56
56
-
context: .
57
57
-
push: ${{ github.event_name != 'pull_request' }}
58
58
-
tags: ${{ steps.meta.outputs.tags }}
59
59
-
labels: ${{ steps.meta.outputs.labels }}
60
60
-
cache-from: type=gha
61
61
-
cache-to: type=gha,mode=max
62
62
-
platforms: linux/amd64,linux/arm64
63
63
-
64
64
-
- name: Image digest
65
65
-
if: github.event_name != 'pull_request'
66
66
-
run: echo "Image pushed successfully"
-132
.github/workflows/rust.yml
···
1
1
-
name: Rust
2
2
-
on:
3
3
-
push:
4
4
-
branches: ["main"]
5
5
-
pull_request:
6
6
-
branches: ["main"]
7
7
-
8
8
-
env:
9
9
-
CARGO_TERM_COLOR: always
10
10
-
11
11
-
jobs:
12
12
-
format:
13
13
-
name: Check format
14
14
-
runs-on: ubuntu-latest
15
15
-
steps:
16
16
-
- uses: actions/checkout@v4
17
17
-
- name: Check format
18
18
-
run: cargo fmt -- --check
19
19
-
20
20
-
lint:
21
21
-
name: Lint
22
22
-
runs-on: ubuntu-latest
23
23
-
steps:
24
24
-
- uses: actions/checkout@v4
25
25
-
- name: Lint all targets
26
26
-
run: cargo clippy --all-targets --all-features -- -D warnings
27
27
-
28
28
-
build:
29
29
-
name: Build
30
30
-
runs-on: ubuntu-latest
31
31
-
steps:
32
32
-
- uses: actions/checkout@v4
33
33
-
- name: Build all binaries
34
34
-
run: cargo build --verbose --all-targets
35
35
-
- name: Build grain binary
36
36
-
run: cargo build --verbose --bin grain
37
37
-
- name: Build grainctl binary
38
38
-
run: cargo build --verbose --bin grainctl
39
39
-
40
40
-
build-release:
41
41
-
name: Build Release
42
42
-
runs-on: ubuntu-latest
43
43
-
steps:
44
44
-
- uses: actions/checkout@v4
45
45
-
- name: Build release binaries
46
46
-
run: cargo build --release --all-targets
47
47
-
- name: Verify grain binary exists
48
48
-
run: test -f target/release/grain
49
49
-
- name: Verify grainctl binary exists
50
50
-
run: test -f target/release/grainctl
51
51
-
- name: Upload grain binary
52
52
-
uses: actions/upload-artifact@v4
53
53
-
with:
54
54
-
name: grain-binary
55
55
-
path: target/release/grain
56
56
-
- name: Upload grainctl binary
57
57
-
uses: actions/upload-artifact@v4
58
58
-
with:
59
59
-
name: grainctl-binary
60
60
-
path: target/release/grainctl
61
61
-
62
62
-
test:
63
63
-
name: Test
64
64
-
runs-on: ubuntu-latest
65
65
-
steps:
66
66
-
- uses: actions/checkout@v4
67
67
-
- name: Run unit tests
68
68
-
run: cargo test --verbose --all-targets
69
69
-
- name: Run integration tests
70
70
-
run: cargo test --verbose --test '*'
71
71
-
72
72
-
e2e-test:
73
73
-
name: E2E Tests
74
74
-
runs-on: ubuntu-latest
75
75
-
needs: build
76
76
-
steps:
77
77
-
- uses: actions/checkout@v4
78
78
-
- name: Build release binaries
79
79
-
run: cargo build --release
80
80
-
- name: Run E2E tests (without Docker)
81
81
-
run: cargo test --verbose --test '*' -- --test-threads=1
82
82
-
- name: Run Docker client tests
83
83
-
run: cargo test --verbose --test docker_client --features docker-tests -- --test-threads=1
84
84
-
continue-on-error: true
85
85
-
- name: Upload test logs on failure
86
86
-
if: failure()
87
87
-
uses: actions/upload-artifact@v4
88
88
-
with:
89
89
-
name: e2e-test-logs
90
90
-
path: |
91
91
-
target/debug/
92
92
-
/tmp/grain-test-*/
93
93
-
retention-days: 3
94
94
-
95
95
-
integration-test:
96
96
-
name: Integration Test
97
97
-
runs-on: ubuntu-latest
98
98
-
needs: build
99
99
-
steps:
100
100
-
- uses: actions/checkout@v4
101
101
-
- name: Build binaries
102
102
-
run: cargo build --release
103
103
-
- name: Create test users file
104
104
-
run: |
105
105
-
mkdir -p tmp
106
106
-
cat > tmp/users.json << 'EOF'
107
107
-
{
108
108
-
"users": [
109
109
-
{
110
110
-
"username": "admin",
111
111
-
"password": "admin",
112
112
-
"permissions": [{"repository": "*", "tag": "*", "actions": ["pull", "push", "delete"]}]
113
113
-
}
114
114
-
]
115
115
-
}
116
116
-
EOF
117
117
-
- name: Start grain server
118
118
-
run: |
119
119
-
./target/release/grain --host 127.0.0.1:8888 --users-file ./tmp/users.json &
120
120
-
sleep 3
121
121
-
- name: Test server is running
122
122
-
run: curl -f -u admin:admin http://127.0.0.1:8888/v2/
123
123
-
- name: Test grainctl list users
124
124
-
run: ./target/release/grainctl user list --url http://127.0.0.1:8888 --username admin --password admin
125
125
-
- name: Test grainctl create user
126
126
-
run: ./target/release/grainctl user create testuser --pass testpass --url http://127.0.0.1:8888 --username admin --password admin
127
127
-
- name: Test grainctl add permission
128
128
-
run: ./target/release/grainctl user add-permission testuser --repository "test/*" --tag "*" --actions "pull" --url http://127.0.0.1:8888 --username admin --password admin
129
129
-
- name: Test grainctl delete user
130
130
-
run: ./target/release/grainctl user delete testuser --url http://127.0.0.1:8888 --username admin --password admin
131
131
-
- name: Stop server
132
132
-
run: pkill -f "grain.*--host" || true