Skip to content

Commit

Permalink
Merge pull request #103 from blackfyre/fix/postcard-sending-feature
Browse files Browse the repository at this point in the history
Fix/postcard sending feature
  • Loading branch information
blackfyre authored Mar 18, 2024
2 parents 11abb02 + 6ff0fa5 commit 2c7bdc8
Show file tree
Hide file tree
Showing 24 changed files with 357 additions and 156 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ WGA_SMTP_USERNAME= # smtp username
WGA_SMTP_PASSWORD= # smtp password
WGA_SENDER_ADDRESS= # sender email address
WGA_SENDER_NAME= # sender name

MAILPIT_URL=http://127.0.0.1:8025 # mailpit url
3 changes: 3 additions & 0 deletions .github/workflows/janitor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ on:
- cron: "0 1 * * *"
jobs:
cleanup:
permissions:
actions: write
contents: write
runs-on: ubuntu-latest
steps:
- name: clean workflow runs
Expand Down
169 changes: 149 additions & 20 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,16 @@ on:
pull_request:
branches: [main]
jobs:
test:
timeout-minutes: 5
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Generate .env file
run: cp .env.example .env
- name: Get installed Playwright version
id: playwright-version
run: echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('./package-lock.json').packages['node_modules/@playwright/test'].version)")" >> $GITHUB_ENV
- uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- name: Cache playwright binaries
uses: actions/cache@v3
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
- name: Install a-h/templ
run: go install github.com/a-h/templ/cmd/templ@latest
- name: Install Taskfile CLI
Expand All @@ -40,19 +27,161 @@ jobs:
run: npm ci
- name: Transpile Frontend
run: task build:frontend
- name: Build the application
run: go build -o wga
- uses: actions/upload-artifact@v4
with:
name: wga_exec
path: wga
retention-days: 1
playwright-tests:
needs: build
timeout-minutes: 5
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4]
shardTotal: [4]
runs-on: ubuntu-latest
environment: playwright
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Fetch the executable
uses: actions/download-artifact@v4
with:
name: wga_exec
path: ./wga_tmp
- name: Download Mailpit
run: wget https://github.com/axllent/mailpit/releases/download/v1.14.4/mailpit-linux-amd64.tar.gz
- name: Install Mailpit
run: tar -xvf mailpit-linux-amd64.tar.gz
- name: Run Mailpit
run: ./mailpit > mailpit.log &
- name: Install NPM dependencies
run: npm ci
- name: Get installed Playwright version
id: playwright-version
run: echo "PLAYWRIGHT_VERSION=$(node -e "console.log(require('./package-lock.json').packages['node_modules/@playwright/test'].version)")" >> $GITHUB_ENV
- name: Cache playwright binaries
uses: actions/cache@v4
id: playwright-cache
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }}
- run: npx playwright install --with-deps
name: Install Playwright
if: steps.playwright-cache.outputs.cache-hit != 'true'
- run: npx playwright install-deps
name: Install Playwright dependencies
if: steps.playwright-cache.outputs.cache-hit != 'true'
- name: Build the application
run: go build -o wga
- name: Add executable permissions
run: chmod +x ./wga_tmp/wga
- name: Run the application
run: ./wga_tmp/wga serve --dev > wga.log &
env:
WGA_PROTOCOL: ${{ vars.WGA_PROTOCOL }}
WGA_HOSTNAME: ${{ vars.WGA_HOSTNAME }}
WGA_ADMIN_EMAIL: ${{ secrets.WGA_ADMIN_EMAIL }}
WGA_ADMIN_PASSWORD: ${{ secrets.WGA_ADMIN_PASSWORD }}
WGA_S3_ENDPOINT: ${{ vars.WGA_S3_ENDPOINT }}
WGA_S3_BUCKET: ${{ vars.WGA_S3_BUCKET }}
WGA_S3_REGION: ""
WGA_S3_ACCESS_KEY: ${{ secrets.WGA_S3_ACCESS_KEY }}
WGA_S3_ACCESS_SECRET: ${{ secrets.WGA_S3_ACCESS_SECRET }}
WGA_SMTP_HOST: ${{ vars.WGA_SMTP_HOST }}
WGA_SMTP_PORT: ${{ vars.WGA_SMTP_PORT }}
WGA_SMTP_USERNAME: ""
WGA_SMTP_PASSWORD: ""
WGA_SENDER_ADDRESS: ${{ vars.WGA_SENDER_ADDRESS }}
WGA_SENDER_NAME: ${{ vars.WGA_SENDER_NAME }}
MAILPIT_URL: ${{ vars.MAILPIT_URL }}
- run: ls -lah ./wga_tmp
- run: ls -lah
- name: Run Playwright tests
run: npx playwright test
run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
env:
WGA_PROTOCOL: ${{ vars.WGA_PROTOCOL }}
WGA_HOSTNAME: ${{ vars.WGA_HOSTNAME }}
WGA_ADMIN_EMAIL: ${{ secrets.WGA_ADMIN_EMAIL }}
WGA_ADMIN_PASSWORD: ${{ secrets.WGA_ADMIN_PASSWORD }}
WGA_S3_ENDPOINT: ${{ vars.WGA_S3_ENDPOINT }}
WGA_S3_BUCKET: ${{ vars.WGA_S3_BUCKET }}
WGA_S3_REGION: ""
WGA_S3_ACCESS_KEY: ${{ secrets.WGA_S3_ACCESS_KEY }}
WGA_S3_ACCESS_SECRET: ${{ secrets.WGA_S3_ACCESS_SECRET }}
WGA_SMTP_HOST: ${{ vars.WGA_SMTP_HOST }}
WGA_SMTP_PORT: ${{ vars.WGA_SMTP_PORT }}
WGA_SMTP_USERNAME: ""
WGA_SMTP_PASSWORD: ""
WGA_SENDER_ADDRESS: ${{ vars.WGA_SENDER_ADDRESS }}
WGA_SENDER_NAME: ${{ vars.WGA_SENDER_NAME }}
MAILPIT_URL: ${{ vars.MAILPIT_URL }}
- uses: actions/upload-artifact@v4
if: always()
with:
name: blob-report-${{ matrix.shardIndex }}
path: blob-report
retention-days: 1
- uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report/
retention-days: 30
name: mailpit-${{ matrix.shardIndex }}
path: mailpit.log
retention-days: 1
- uses: actions/upload-artifact@v4
if: failure()
with:
name: wga-log-${{ matrix.shardIndex }}
path: wga.log
retention-days: 1
- uses: actions/upload-artifact@v4
if: failure()
with:
name: wga-data-${{ matrix.shardIndex }}
path: wga_data
retention-days: 1
merge-reports:
# Merge reports after playwright-tests, even if some shards have failed
if: always()
needs: [playwright-tests]
environment: playwright
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
- name: Install dependencies
run: npm ci

- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v4
with:
path: all-blob-reports
pattern: blob-report-*
merge-multiple: true

- name: Merge into HTML Report
run: npx playwright merge-reports --reporter html ./all-blob-reports

- name: Upload HTML report
uses: actions/upload-artifact@v4
with:
name: html-report--attempt-${{ github.run_attempt }}
path: playwright-report
retention-days: 14
- name: Upload HTML report to Azure
shell: bash
run: |
REPORT_DIR='run-${{ github.run_id }}-${{ github.run_attempt }}'
azcopy cp --recursive "./playwright-report/*" "https://wga.blob.core.windows.net/\$web/$REPORT_DIR"
echo "::notice title=HTML report url::https://wga.z6.web.core.windows.net/$REPORT_DIR/index.html"
env:
AZCOPY_AUTO_LOGIN_TYPE: SPN
AZCOPY_SPA_APPLICATION_ID: "${{ secrets.AZCOPY_SPA_APPLICATION_ID }}"
AZCOPY_SPA_CLIENT_SECRET: "${{ secrets.AZCOPY_SPA_CLIENT_SECRET }}"
AZCOPY_TENANT_ID: "${{ secrets.AZCOPY_TENANT_ID }}"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ wga_data
wga_sitemap
analytics.txt
.env
wga

# Go build related files
dist/
Expand Down
9 changes: 9 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,27 @@
},
"cSpell.words": [
"Artform",
"Automigrate",
"bluemonday",
"bulma",
"daos",
"esbuild",
"fontawesome",
"goarch",
"godotenv",
"Goreleaser",
"Htmx",
"isaack",
"koedijck",
"labstack",
"Lexend",
"Mailpit",
"migratecmd",
"pocketbase",
"sabloger",
"templ",
"tmpl",
"trix",
"Upsert"
]
}
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Introduction

This repositry contains the code for the Web Gallery of Art project. The project is a web application that allows users to browse through a collection of paintings, sculptures and other forms of Art. This project is inteded to shave off the 3 decades of tech debt on the original website and provide a modern, responsive and user friendly experience with the same content.
This repository contains the code for the Web Gallery of Art project. The project is a web application that allows users to browse through a collection of paintings, sculptures and other forms of Art. This project is intended to shave off the 3 decades of tech debt on the original website and provide a modern, responsive and user friendly experience with the same content.

## Technologies

Expand All @@ -23,7 +23,7 @@ The project is built using the following technologies:

To run the application you'll have to have a `.env` file next to your executable with the following contents:

```bash {"id":"01HG08MCJXSNDZ9CYZ40JF0V9R"}
```bash
WGA_ENV=development

WGA_ADMIN_EMAIL=
Expand All @@ -44,6 +44,8 @@ WGA_SMTP_USERNAME=
WGA_SMTP_PASSWORD=
WGA_SENDER_ADDRESS=
WGA_SENDER_NAME=

MAILPIT_URL=
```

| Variable | Description |
Expand All @@ -59,17 +61,18 @@ WGA_SENDER_NAME=
| `WGA_PROTOCOL` | The protocol to use for the application, valid values are `http` and `https` |
| `WGA_HOSTNAME` | The domain pointing to the application |
| `WGA_SMTP_HOST` | The address of the SMTP host |
| `WGA_SMTP_PORT` | The SMTP service port on the host adress |
| `WGA_SMTP_PORT` | The SMTP service port on the host address |
| `WGA_SMTP_USERNAME` | The username for the SMTP service |
| `WGA_SMTP_PASSWORD` | The password for the SMTP service |
| `WGA_SENDER_ADDRESS` | The sending email address |
| `WGA_SENDER_NAME` | The name of the email sender |
| `MAILPIT_URL` | For testing only! |

### Running the application

To run the application simply download the release for your platform and run it with:

```bash {"id":"01HG08MCJYF04DTTTHQB8QKM5Z"}
```bash
./wga serve
```

Expand All @@ -90,7 +93,7 @@ To build the application you will need to have the following installed:

Building the application relies on [Goreleaser](https://goreleaser.com/) to build the application. To build the application simply run:

```bash {"id":"01HG08MCJYF04DTTTHQC3TYW4M"}
```bash
goreleaser release --snapshot --clean
```

Expand Down
2 changes: 1 addition & 1 deletion assets/templ/components/feedback.templ
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ templ FeedbackForm() {
hx-post="/feedback"
enctype="multipart/form-data"
hx-target="#d"
id="postcard_create"
id="feedback_send_form"
hx-select="section.container"
hx-swap="innerHTML"
>
Expand Down
4 changes: 2 additions & 2 deletions assets/templ/pages/guestbook.templ
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ templ GuestbookEntryForm() {
}

templ GuestbookEntries(entries []*models.GuestbookEntry) {
<div class="list has-hoverable-list-items">
<div class="list has-hoverable-list-items gb-entries">
for _, entry := range entries {
@GuestbookEntry(entry)
}
Expand All @@ -162,7 +162,7 @@ templ GuestbookEntry(entry *models.GuestbookEntry) {
if (entry.Message == "") {
return
}
<div class="list-item">
<div class="list-item gb-entry">
<div class="list-item-image">
<figure class="image is-64x64">
if entry.Email != "" {
Expand Down
Loading

0 comments on commit 2c7bdc8

Please sign in to comment.