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

OpenTofu Installer #1

Merged
21 commits merged into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Test
on:
pull_request:
jobs:
linux:
name: Linux
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: true
matrix:
distro: [alpine, debian, fedora, opensuse, rocky, ubuntu]
method: [brew, repo, standalone]
shell: [ash, bash, dash, ksh, zsh]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Cosign
uses: sigstore/[email protected]
- name: Test
env:
DISTRO: ${{ matrix.distro }}
METHOD: ${{ matrix.method }}
SH: ${{ matrix.shell }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd tests/linux
This conversation was marked as resolved.
Show resolved Hide resolved
./test.sh
macos:
name: MacOS
runs-on: macos-latest
strategy:
fail-fast: true
matrix:
method: [brew, standalone]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Cosign
uses: sigstore/[email protected]
- name: Test
run: |
cd tests/macos
./${{ matrix.method }}.sh
widows:
name: Windows
runs-on: windows-latest
strategy:
fail-fast: true
matrix:
method: [standalone]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Cosign
uses: sigstore/[email protected]
- name: Test
working-directory: tests\windows
run: .\test.ps1 -method "${{ matrix.method }}"
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,27 @@
# OpenTofu distribution site

This repository contains the source code for the `get.opentofu.org` distribution site. It is deployed on Cloudflare
Pages. The installation script is located in [`src/install.sh`](src/install.sh), which is a combined POSIX/Powershell
script. The Cloudflare function managing the MIME type assignment is located in
Pages. The installation scripts are located in [`src/install-opentofu.sh`](src/install-opentofu.sh) (POSIX) and [`src/install-opentofu.ps1`](src/install-opentofu.ps1) (Powershell). The Cloudflare function managing the MIME type assignment is located in
[`src/functions/index.ts`](src/functions/index.ts).

## Testing the script (Linux only, WIP)
## Testing the script

### Linux

You can test the installation script manually, or you can use `docker compose` to run the automated

You can test the [installation script](src/install.sh) manually, or you can use `docker compose` to run the automated
tests:

```bash
cd tests/linux
./test-all.sh
```
cd tests
./test.sh

### Windows

```powershell
cd tests\windows
& '.\test-all.ps1'
```

## Testing the site
Expand Down
4 changes: 2 additions & 2 deletions src/functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ interface Env {
export const onRequest: PagesFunction<Env> = async (context) => {
const userAgent = context.request.headers.get("user-agent").toLowerCase()
const url = new URL(context.request.url)
url.pathname = "/install.sh"
url.pathname = "/install-opentofu." + (userAgent.includes("windows")?"ps1":"sh")
const asset = await context.env.ASSETS.fetch(url)
return new Response(asset.body, {
status: 200,
headers: {
'content-type': 'text/x-shellscript',
'content-disposition': 'attachment; filename=opentofu-install.' + (userAgent.includes("windows")?"ps1":"sh"),
'content-disposition': 'attachment; filename=install-opentofu.' + (userAgent.includes("windows")?"ps1":"sh"),
'vary': 'user-agent'
},
});
Expand Down
Loading