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

Handle private repositories dependencies #31

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

rvignolo
Copy link

@rvignolo rvignolo commented May 17, 2024

An action would look like:

name: CI

on:
  push:
    branches:
      - mainnet
      - devnet
      - develop
  pull_request:
    branches:
      - mainnet
      - devnet
      - develop

permissions:
  checks: write
  contents: read
  pull-requests: write

jobs:
  contracts:
    name: Contracts
    uses: HatomProtocol/hatom-sc-actions/.github/workflows/contracts.yml@main
    with:
      rust-toolchain: nightly-2023-12-11
    secrets:
      token: ${{ secrets.GITHUB_TOKEN }}
      deploy-keys: |
        ${{ secrets.SC_REPOSITORY_1_SSH_DEPLOY_PRIVATE_KEY }}
        ${{ secrets.SC_REPOSITORY_2_SSH_DEPLOY_PRIVATE_KEY }}

or

name: On release, build contracts

on:
  release:
    types: [published]

permissions:
  contents: write

jobs:
  build:
    uses: HatomProtocol/hatom-sc-actions/.github/workflows/reproducible-build.yml@main
    with:
      image_tag: v6.1.1
      attach_to_existing_release: true
      package_whole_project_src: true
    secrets:
      deploy-keys: |
        ${{ secrets.SC_REPOSITORY_1_SSH_DEPLOY_PRIVATE_KEY }}
        ${{ secrets.SC_REPOSITORY_2_SSH_DEPLOY_PRIVATE_KEY }}

* feat: ✨ try support for multiple private repositories

* fix: 🐛 try one pk only

* feat: ✨ use multiple keys

* feat: ✨ add admin module pk

* fix: 🐛 some fixes

* try one key

* revert: ⏪ simpler approach

* feat: ✨ add CARGO_NET_GIT_FETCH_WITH_CLI env

* revert: 💚 try something out

* feat: ✨ use deploy keys

* feat: ✨ add cargo vendor

* fix: 🐛 add CARGO_NET_GIT_FETCH_WITH_CLI at reproducible build

* fix: 🐛 do not compile vendor directories

* fix: 🐛 minor fix

* fix:

* fix: 🔥 avoid jq install
* feat: 🚧 try deploy keys as unique var

* feat: ⚡ remove private dependencies input var

* fix: 🐛 final fixes
@rvignolo rvignolo changed the title Handle private repository dependencies Handle private repositories dependencies May 17, 2024
@andreibancioiu andreibancioiu self-requested a review May 20, 2024 07:17
@rvignolo
Copy link
Author

any updates @andreibancioiu ? thank you!

@@ -110,17 +121,20 @@ jobs:
- name: Build the wasm contracts
env:
RUSTFLAGS: ""
CARGO_NET_GIT_FETCH_WITH_CLI: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +71 to +78
- name: Setup Credentials
uses: webfactory/[email protected]
env:
SUPER_SECRET: ${{ secrets.deploy-keys }}
if: ${{ env.SUPER_SECRET != '' }}
with:
ssh-private-key: ${{ secrets.deploy-keys }}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd like to avoid using an additional third party step, if possible (and only have it as a last resort).

toolchain: ${{ inputs.rust-toolchain }}
target: wasm32-unknown-unknown

- name: Vendored dependencies (if private dependencies are used)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thus, private dependencies are brought locally, before starting the build, correct (sorry if I misunderstood)?

If so, the usual contract verification flow (which relies on the Docker container to perform the whole build) would not be able to cover this case (however, for verified contracts, private dependencies would not be acceptable, anyway).

@@ -196,6 +210,14 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Setup Credentials
Copy link
Contributor

@andreibancioiu andreibancioiu May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For contracts.yml (not for reproducible-build.yml), the solution you've previously provided (without altering contracts.yml) seems sufficient (an additional step in the workflow file of the repository itself):

multiversx/mx-sdk-rust-contract-builder#59 (comment)

Maybe we can promote and document that solution, and have contracts.yml untouched (at least, from the perspective of setting up credentials)?

@@ -86,6 +90,42 @@ jobs:
fetch-depth: 0
repository: ${{ env.GITHUB_REPOSITORY }}

- name: Setup Credentials
Copy link
Contributor

@andreibancioiu andreibancioiu May 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We understand the need of a closed-source contract to depend on private dependencies, e.g. for development phase 👍 - of course, this is not wise for contracts deployed on mainnet - such contracts cannot pass the verified and reproducible build check.

Though, how would you feel about the options below?

(A) have your private dependencies brought as git submodules in your main private repository, then alter the Cargo.toml to point to them (of course, making your project open-source would reveal the source code of the dependencies, as well).

(B) in the Docker images for reproducible builds, we can enable ssh-agent, and run ssh-add (if any key is provided in the Docker environment) - I did not yet test this approach, though.

(C) allow reproducible-build.yml to be parametrized with the fully qualified-name of a Docker image (instead of image_tag only) - this way, you can use a custom Docker image to perform the build of a closed-source contract.

@andreibancioiu
Copy link
Contributor

@rvignolo, sorry for the delayed response 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants