Skip to content

Commit

Permalink
Convenience script implementation
Browse files Browse the repository at this point in the history
Signed-off-by: Janos Bonic <[email protected]>
Co-authored-by: Christian Mesh <[email protected]>
  • Loading branch information
Janos Bonic and cam72cam committed Jan 4, 2024
1 parent 78567ae commit bad9180
Show file tree
Hide file tree
Showing 53 changed files with 2,335 additions and 919 deletions.
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
./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 }}"
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
# 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

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

You can test the installation scriptmanually, 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

0 comments on commit bad9180

Please sign in to comment.