Skip to content
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

Create docker_build.yml #496

Merged
merged 3 commits into from
Nov 8, 2024
Merged

Create docker_build.yml #496

merged 3 commits into from
Nov 8, 2024

Conversation

leonardocustodio
Copy link
Owner

@leonardocustodio leonardocustodio commented Nov 8, 2024

PR Type

enhancement, configuration changes


Description

  • Introduced a new GitHub Actions workflow to automate Docker image builds.
  • The workflow is triggered on pull requests and uses the latest Ubuntu runner.
  • It includes steps to check out the repository and build a Docker image.

Changes walkthrough 📝

Relevant files
Configuration changes
docker_build.yml
Add GitHub Actions workflow for Docker image builds           

.github/workflows/docker_build.yml

  • Added a new GitHub Actions workflow for Docker image builds.
  • Configured the workflow to trigger on pull requests.
  • Set up a job to build a Docker image using the latest Ubuntu runner.
  • Included a step to check out the repository code.
  • +14/-0   

    💡 PR-Agent usage: Comment /help "your question" on any pull request to receive relevant information

    Copy link

    github-actions bot commented Nov 8, 2024

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ No major issues detected

    Copy link

    github-actions bot commented Nov 8, 2024

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Score
    Performance
    Speed up Docker builds by caching layers

    Add a cache step to reuse Docker layers from previous builds to speed up the build
    process.

    .github/workflows/docker_build.yml [9-13]

     steps:
       - uses: actions/checkout@v4
    +  - name: Set up Docker Buildx
    +    uses: docker/setup-buildx-action@v1
    +  - name: Cache Docker layers
    +    uses: actions/cache@v2
    +    with:
    +      path: /tmp/.buildx-cache
    +      key: ${{ runner.os }}-buildx-${{ github.sha }}
    +      restore-keys: |
    +        ${{ runner.os }}-buildx-
       - name: Build docker image
         run: |
    -      docker build -t leonardocustodio/polkadart .
    +      docker build --cache-from /tmp/.buildx-cache -t leonardocustodio/polkadart .
    Suggestion importance[1-10]: 9

    Why: Implementing caching for Docker builds can significantly reduce build times and resource usage, making this a highly impactful suggestion for improving the CI pipeline's performance.

    9
    Best practice
    Ensure Docker Hub authentication for potential image pushes

    Add a step to log in to Docker Hub before building the Docker image to ensure the
    process can push the image if needed.

    .github/workflows/docker_build.yml [9-13]

     steps:
       - uses: actions/checkout@v4
    +  - name: Log in to Docker Hub
    +    uses: docker/login-action@v1
    +    with:
    +      username: ${{ secrets.DOCKER_USERNAME }}
    +      password: ${{ secrets.DOCKER_PASSWORD }}
       - name: Build docker image
         run: |
           docker build -t leonardocustodio/polkadart .
    Suggestion importance[1-10]: 8

    Why: Adding a Docker Hub login step is crucial for workflows that may push images, ensuring authentication is handled before the build process. This suggestion correctly identifies a missing step in the Docker build process.

    8
    Enhancement
    Limit Docker image builds to specific branches to optimize CI resources

    Specify the branch names for the pull_request event to avoid unnecessary builds on
    all branches.

    .github/workflows/docker_build.yml [3-4]

     on:
       pull_request:
    +    branches:
    +      - main
    +      - develop
    Suggestion importance[1-10]: 7

    Why: This suggestion effectively limits CI builds to specific branches, reducing unnecessary resource usage and improving efficiency. It is directly applicable to the 'on: pull_request:' section of the YAML.

    7
    Clarify the Docker build context and Dockerfile location

    Use a Docker build context and specify a Dockerfile if not using the default
    location to enhance clarity and flexibility in builds.

    .github/workflows/docker_build.yml [13-14]

     run: |
    -  docker build -t leonardocustodio/polkadart .
    +  docker build -t leonardocustodio/polkadart -f ./Dockerfile .
    Suggestion importance[1-10]: 5

    Why: Specifying the Dockerfile location can enhance clarity and flexibility, especially in complex projects. However, this is a minor enhancement as it assumes non-standard Dockerfile locations or contexts which may not be necessary for all projects.

    5

    Copy link

    codecov bot commented Nov 8, 2024

    Codecov Report

    All modified and coverable lines are covered by tests ✅

    Project coverage is 48.48%. Comparing base (9748fd9) to head (0d7d6bf).
    Report is 1 commits behind head on main.

    Additional details and impacted files

    Impacted file tree graph

    @@            Coverage Diff             @@
    ##             main     #496      +/-   ##
    ==========================================
    + Coverage   48.36%   48.48%   +0.12%     
    ==========================================
      Files         176      181       +5     
      Lines        9439     9588     +149     
    ==========================================
    + Hits         4565     4649      +84     
    - Misses       4874     4939      +65     
    Flag Coverage Δ
    polkadart 15.89% <ø> (ø)
    polkadart_cli 12.04% <ø> (ø)
    polkadart_keyring 65.24% <ø> (ø)
    polkadart_scale_codec 54.93% <ø> (ø)
    secp256k1_ecdsa 89.60% <ø> (ø)
    sr25519 85.91% <ø> (ø)
    ss58 96.87% <ø> (ø)
    substrate_bip39 56.37% <ø> (?)
    substrate_metadata 87.72% <ø> (ø)

    Flags with carried forward coverage won't be shown. Click here to find out more.

    see 5 files with indirect coverage changes

    @leonardocustodio leonardocustodio merged commit 591782e into main Nov 8, 2024
    15 checks passed
    @leonardocustodio leonardocustodio deleted the leonardocustodio-patch-1 branch November 8, 2024 17:21
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    2 participants