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

Request: Support for GitHub Action #556

Closed
RDhar opened this issue Sep 22, 2023 · 8 comments · Fixed by opentofu/setup-opentofu#2
Closed

Request: Support for GitHub Action #556

RDhar opened this issue Sep 22, 2023 · 8 comments · Fixed by opentofu/setup-opentofu#2
Assignees
Labels
accepted This issue has been accepted for implementation. enhancement New feature or request

Comments

@RDhar
Copy link
Contributor

RDhar commented Sep 22, 2023

OpenTofu Version

>1.5, >1.6

Use Cases

As a platforms IaC guy, I'm heavily reliant on the hashicorp/setup-terraform GitHub Action in order to provision TF via automation. Here's an example in situ.

Am I right to assume that an OpenTofu equivalent of that GitHub Action will be available from initial release? Just to make it super-accessible as a drop-in replacement at scale.

If so, more than happy to help validate preview releases across a extensive AWS IaC projects I work on.

Attempted Solutions

Thanks to @zimeg (from Slack), a serviceable workaround exists by downloading, installing and initializing the OpenTofu CLI in 3 steps (as per BUILDING.md instructions).

- name: Download the tofu source
  uses: actions/checkout@v4
  with:
    repository: opentofu/opentofu
    path: opentofu

- name: Install tofu tooling
  uses: actions/setup-go@v4
  with:
    go-version-file: opentofu/go.mod
    cache-dependency-path: opentofu/go.sum

- name: Prepare the tofu command
  working-directory: opentofu
  run: |
    go build -ldflags "-w -s -X 'github.com/opentofu/opentofu/version.dev=no'" -o bin/tofu .
    echo $(pwd)/bin >> $GITHUB_PATH

Proposal

As of writing this, I can see that a proposed opentofu/setup-opentofu already work-in-progress. I'll keep an eye on releases for the repo and support any testing endeavour.

There is also a relevant discussion in #411 started by @John-Donalson.

References

While this is in direct reference to the hashicorp/setup-terraform GitHub Action, I'm hesitant to directly link to it as it's not an OpenTofu project (even though it is currently MPL-2.0 licensed).

@RDhar RDhar added enhancement New feature or request pending-decision This issue has not been accepted for implementation nor rejected. It's still open to discussion. labels Sep 22, 2023
@kislerdm
Copy link
Contributor

I'd be glad to give a hand and commit to delivering the github action. I reckon it can be defined even simpler compared to the terraform-setup action.

@cube2222
Copy link
Contributor

Sounds good to me!

Discussion on Slack might also be relevant.

Assigning this to you @kislerdm. I've created a repo here: https://github.com/opentofu/setup-opentofu
One more question, will this be based on the existing setup-terraform action, or completely from scratch? Depending on that the license should either be MPL (if it's based on the existing action) or apache (if it's from scratch).

Quick additional note, this is not an alpha release blocker.

@cube2222 cube2222 added accepted This issue has been accepted for implementation. and removed pending-decision This issue has not been accepted for implementation nor rejected. It's still open to discussion. labels Sep 25, 2023
@RDhar
Copy link
Contributor Author

RDhar commented Sep 25, 2023

Thank you for picking up on this, @kislerdm and @cube2222.

For clarity, I've fleshed out the description with a little more detail, including a serviceable GitHub Action workaround as suggested by @zimeg (from Slack), for those who are interested in trying out the bleeding edge of OpenTofu in its current form.

@kislerdm
Copy link
Contributor

kislerdm commented Sep 25, 2023

@cube2222 Hey Kuba! Thanks for assigning the issue.

One more question, will this be based on the existing setup-terraform action, or completely from scratch?

Either option will have its pro and cons.

The main pro to develop from scratch: simplification of the code, and bug fixes - some bugs are pending execution for months.

The main con: effort investment and delivery time.

Given the above, I'd propose to initially release setup-opentofu action as a reworked fork of setup-terraform to enable users to swap terraform with tofu in their CI pipelines seamlessly. Afterwards, setup-opentofu can we reworked to incorporate long-pending requests for setup-terraform.

WDYT?

@cube2222
Copy link
Contributor

Sounds good to me @kislerdm!

@kislerdm
Copy link
Contributor

kislerdm commented Oct 2, 2023

Hey folks! I'd like to share a progress update.

  • Action is defined as the composite action. The rationale: simple way of building from source until the official release.
  • Release of the CLI wrapper to set the outputs according to the setup-terraform action's interface definition. I decided to build a wrapper in Go for two reasons:
    • The GitHub action is defined as the composite action, hence no need to committing to more technologies than Go - the tofu base technology.
    • The setup-terraform js action relies on the hashicorp js library used to resolve the terraform version. That library uses hardcored values for the tf registry, hence unfortunately we could not reuse it without forking and committing to the fork maintenance.

Unfortunately, I had to switch context from this issue for a couple of days. I'll focus back on it in the second half of this week. Thanks!

@eranelbaz
Copy link
Contributor

Hey @kislerdm need any help to push this one forward?

@kislerdm
Copy link
Contributor

kislerdm commented Oct 5, 2023

@eranelbaz Hey Elbaz! Could you please review the PR? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted This issue has been accepted for implementation. enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants