Skip to content

Commit bad9180

Browse files
Janos Boniccam72cam
andcommitted
Convenience script implementation
Signed-off-by: Janos Bonic <[email protected]> Co-authored-by: Christian Mesh <[email protected]>
1 parent 78567ae commit bad9180

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2335
-919
lines changed

.github/workflows/test.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Test
2+
on:
3+
pull_request:
4+
jobs:
5+
linux:
6+
name: Linux
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: read
10+
strategy:
11+
fail-fast: true
12+
matrix:
13+
distro: [alpine, debian, fedora, opensuse, rocky, ubuntu]
14+
method: [brew, repo, standalone]
15+
shell: [ash, bash, dash, ksh, zsh]
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
- name: Install Cosign
20+
uses: sigstore/[email protected]
21+
- name: Test
22+
env:
23+
DISTRO: ${{ matrix.distro }}
24+
METHOD: ${{ matrix.method }}
25+
SH: ${{ matrix.shell }}
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
run: |
28+
cd tests/linux
29+
./test.sh
30+
macos:
31+
name: MacOS
32+
runs-on: macos-latest
33+
strategy:
34+
fail-fast: true
35+
matrix:
36+
method: [brew, standalone]
37+
steps:
38+
- name: Checkout
39+
uses: actions/checkout@v4
40+
- name: Install Cosign
41+
uses: sigstore/[email protected]
42+
- name: Test
43+
run: |
44+
cd tests/macos
45+
./${{ matrix.method }}.sh
46+
widows:
47+
name: Windows
48+
runs-on: windows-latest
49+
strategy:
50+
fail-fast: true
51+
matrix:
52+
method: [standalone]
53+
steps:
54+
- name: Checkout
55+
uses: actions/checkout@v4
56+
- name: Install Cosign
57+
uses: sigstore/[email protected]
58+
- name: Test
59+
working-directory: tests\windows
60+
run: .\test.ps1 -method "${{ matrix.method }}"

README.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
# OpenTofu distribution site
22

33
This repository contains the source code for the `get.opentofu.org` distribution site. It is deployed on Cloudflare
4-
Pages. The installation script is located in [`src/install.sh`](src/install.sh), which is a combined POSIX/Powershell
5-
script. The Cloudflare function managing the MIME type assignment is located in
4+
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
65
[`src/functions/index.ts`](src/functions/index.ts).
76

8-
## Testing the script (Linux only, WIP)
7+
## Testing the script
98

10-
You can test the [installation script](src/install.sh) manually, or you can use `docker compose` to run the automated
9+
### Linux
10+
11+
You can test the installation scriptmanually, or you can use `docker compose` to run the automated
1112
tests:
1213

14+
```bash
15+
cd tests/linux
16+
./test-all.sh
1317
```
14-
cd tests
15-
./test.sh
18+
19+
### Windows
20+
21+
```powershell
22+
cd tests\windows
23+
& '.\test-all.ps1'
1624
```
1725

1826
## Testing the site

src/functions/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ interface Env {
77
export const onRequest: PagesFunction<Env> = async (context) => {
88
const userAgent = context.request.headers.get("user-agent").toLowerCase()
99
const url = new URL(context.request.url)
10-
url.pathname = "/install.sh"
10+
url.pathname = "/install-opentofu." + (userAgent.includes("windows")?"ps1":"sh")
1111
const asset = await context.env.ASSETS.fetch(url)
1212
return new Response(asset.body, {
1313
status: 200,
1414
headers: {
1515
'content-type': 'text/x-shellscript',
16-
'content-disposition': 'attachment; filename=opentofu-install.' + (userAgent.includes("windows")?"ps1":"sh"),
16+
'content-disposition': 'attachment; filename=install-opentofu.' + (userAgent.includes("windows")?"ps1":"sh"),
1717
'vary': 'user-agent'
1818
},
1919
});

0 commit comments

Comments
 (0)