-
Notifications
You must be signed in to change notification settings - Fork 0
Add pipeline CI/CD #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
52efb1e
Add pipeline CI/CD
788f828
update
4fbe49d
update
b2c82fd
update
cfe6d1c
update
81d9b25
update
22ac5db
update
bde9f85
updaet
feb1469
updaet
b078ed8
updaet
3019f26
updaet
3a60daf
updaet
90b1c41
updaet
1b79da3
updaet
18d3361
updaet
7ab80d2
updaet
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,175 @@ | ||
| name: Enokiweave CI/CD | ||
|
|
||
| permissions: {} # Default to no permissions | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ '**' ] | ||
| workflow_dispatch: | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
| REGISTRY: docker.io | ||
| REPOSITORY: myceliumai | ||
| IMAGE_NAME: enokiweave | ||
|
|
||
| jobs: | ||
| changes: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| pull-requests: read | ||
| contents: read | ||
| outputs: | ||
| core: ${{ steps.filter.outputs.core }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: dorny/paths-filter@v3 | ||
| id: filter | ||
| with: | ||
| filters: | | ||
| core: | ||
| - 'src/**' | ||
| - 'Cargo.*' | ||
| - '.github/workflows/**' | ||
| - 'Dockerfile' | ||
|
|
||
| check: | ||
| needs: changes | ||
| if: ${{ needs.changes.outputs.core == 'true' }} | ||
| name: Check | ||
| runs-on: ubuntu-latest | ||
| continue-on-error: true | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Checkout sources | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install stable toolchain | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| components: rustfmt, clippy | ||
|
|
||
| - name: Set up cargo cache | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: | | ||
| ~/.cargo/bin/ | ||
| ~/.cargo/registry/index/ | ||
| ~/.cargo/registry/cache/ | ||
| ~/.cargo/git/db/ | ||
| target/ | ||
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
| restore-keys: ${{ runner.os }}-cargo- | ||
|
|
||
| - name: Install LMDB | ||
| run: sudo apt-get update && sudo apt-get install -y liblmdb-dev | ||
|
|
||
| - name: Run cargo fmt | ||
| run: cargo fmt --all -- --check | ||
|
|
||
| - name: Run cargo clippy | ||
| run: cargo clippy -- -D warnings | ||
|
|
||
| test: | ||
| needs: changes | ||
| if: ${{ needs.changes.outputs.core == 'true' }} | ||
| name: Test Suite | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Checkout sources | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Install stable toolchain | ||
| uses: dtolnay/rust-toolchain@stable | ||
|
|
||
| - name: Set up cargo cache | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: | | ||
| ~/.cargo/bin/ | ||
| ~/.cargo/registry/index/ | ||
| ~/.cargo/registry/cache/ | ||
| ~/.cargo/git/db/ | ||
| target/ | ||
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
| restore-keys: ${{ runner.os }}-cargo- | ||
|
|
||
| - name: Install LMDB | ||
| run: sudo apt-get update && sudo apt-get install -y liblmdb-dev | ||
|
|
||
| - name: Run cargo test | ||
| run: cargo test | ||
|
|
||
| security: | ||
| name: Security Checks | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| security-events: write | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: aquasecurity/trivy-action@master | ||
| with: | ||
| scan-type: 'fs' | ||
| scan-ref: '.' | ||
| format: 'sarif' | ||
| output: 'trivy-results.sarif' | ||
| severity: 'CRITICAL,HIGH' | ||
| scanners: 'vuln,secret,config' | ||
| - uses: github/codeql-action/upload-sarif@v2 | ||
| with: | ||
| sarif_file: 'trivy-results.sarif' | ||
| category: 'trivy' | ||
|
|
||
| build: | ||
| needs: [changes, security, check, test] | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: Check if should build | ||
| id: should_build | ||
| run: | | ||
| if [[ | ||
| "${{ github.event_name }}" == "push" && | ||
| "${{ github.ref }}" == "refs/heads/main" && | ||
| "${{ needs.changes.outputs.core }}" == "true" | ||
| ]]; then | ||
| echo "run=true" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - uses: actions/checkout@v4 | ||
| if: steps.should_build.outputs.run == 'true' | ||
|
|
||
| - uses: docker/setup-buildx-action@v3 | ||
| if: steps.should_build.outputs.run == 'true' | ||
|
|
||
| - uses: docker/login-action@v3 | ||
| if: steps.should_build.outputs.run == 'true' | ||
| with: | ||
| registry: ${{ env.REGISTRY }} | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
|
||
| - uses: docker/metadata-action@v5 | ||
| if: steps.should_build.outputs.run == 'true' | ||
| id: meta | ||
| with: | ||
| images: ${{ env.REGISTRY }}/${{ env.REPOSITORY }}/${{ env.IMAGE_NAME }} | ||
| tags: | | ||
| type=raw,value=latest | ||
| type=sha,format=long | ||
|
|
||
| - uses: docker/build-push-action@v5 | ||
| if: steps.should_build.outputs.run == 'true' | ||
| with: | ||
| context: . | ||
| push: true | ||
| tags: ${{ steps.meta.outputs.tags }} | ||
| labels: ${{ steps.meta.outputs.labels }} | ||
| cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPOSITORY }}/${{ env.IMAGE_NAME }}:buildcache | ||
| cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.REPOSITORY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # Build stage | ||
|
||
| FROM rust:1.75-slim-bullseye as builder | ||
|
|
||
| # Install system dependencies | ||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends \ | ||
| pkg-config \ | ||
| liblmdb-dev \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Create a new empty shell project | ||
| WORKDIR /usr/src/enokiweave | ||
|
|
||
| # Copy manifests | ||
| COPY Cargo.lock Cargo.toml ./ | ||
|
|
||
| # Copy source code | ||
| COPY src ./src | ||
| COPY setup ./setup | ||
|
|
||
| # Build for release | ||
| RUN cargo build --release | ||
|
|
||
| # Runtime stage | ||
| FROM debian:bullseye-slim | ||
|
|
||
| # Install runtime dependencies | ||
| RUN apt-get update && \ | ||
| apt-get install -y --no-install-recommends \ | ||
| liblmdb0 \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| # Create non-root user | ||
| RUN groupadd -r enoki && useradd -r -g enoki enoki | ||
|
|
||
| # Create necessary directories and set permissions | ||
| RUN mkdir -p /var/lib/enokiweave /etc/enokiweave && \ | ||
| chown -R enoki:enoki /var/lib/enokiweave /etc/enokiweave | ||
|
|
||
| # Copy the build artifacts from builder | ||
| COPY --from=builder /usr/src/enokiweave/target/release/enokiweave /usr/local/bin/ | ||
| COPY --from=builder /usr/src/enokiweave/target/release/build-transaction /usr/local/bin/ | ||
|
|
||
| # Copy configuration files | ||
| COPY setup/example_genesis_file.json /etc/enokiweave/genesis.json | ||
| COPY setup/example_initial_peers_file.txt /etc/enokiweave/peers.txt | ||
|
|
||
| # Set working directory | ||
| WORKDIR /var/lib/enokiweave | ||
|
|
||
| # Switch to non-root user | ||
| USER enoki | ||
|
|
||
| # Expose ports | ||
| EXPOSE 3001 | ||
|
|
||
| # Add healthcheck | ||
| HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ | ||
| CMD curl -f http://localhost:3001/health || exit 1 | ||
|
|
||
| # Set entrypoint | ||
| ENTRYPOINT ["enokiweave"] | ||
| CMD ["--genesis-file-path", "/etc/enokiweave/genesis.json", "--rpc_port", "3001"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| version: '3.8' | ||
|
|
||
| services: | ||
| enokiweave: | ||
| image: ${DOCKER_HUB_USERNAME}/enokiweave:latest | ||
| ports: | ||
| - "3001:3001" | ||
| volumes: | ||
| - enokiweave-data:/var/lib/enokiweave | ||
| - ./setup/example_genesis_file.json:/etc/enokiweave/genesis.json | ||
| - ./setup/example_initial_peers_file.txt:/etc/enokiweave/peers.txt | ||
| environment: | ||
| - RUST_LOG=info | ||
| restart: unless-stopped | ||
|
|
||
| volumes: | ||
| enokiweave-data: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.