Skip to content

Commit

Permalink
Merge pull request #5 from participating-online/draft/xenodochial-bush
Browse files Browse the repository at this point in the history
Big refactor and code cleanup from WIP/POC
  • Loading branch information
lazyguru authored Nov 27, 2023
2 parents 08f1771 + 4d45a0c commit bdabbbf
Show file tree
Hide file tree
Showing 26 changed files with 502 additions and 856 deletions.
4 changes: 3 additions & 1 deletion .codesandbox/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"port": 8080
},
"restartOn": {
"files": ["*"]
"files": ["*"],
"branch": true,
"resume": true
}
}
}
Expand Down
7 changes: 0 additions & 7 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
FROM golang:1.21.4-bullseye

COPY install-turso.sh /tmp/install-turso.sh

RUN chmod +x /tmp/install-turso.sh && \
/tmp/install-turso.sh && \
rm /tmp/install-turso.sh && \
ln -s /root/.turso/turso /bin/turso
5 changes: 3 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "Devcontainer",
"build": {
"dockerfile": "./Dockerfile"
// Path is relative to the devcontainer.json file.
"dockerfile": "Dockerfile"
}
}
}
158 changes: 0 additions & 158 deletions .devcontainer/install-turso.sh

This file was deleted.

1 change: 0 additions & 1 deletion .env-sample
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export DB_URL="libsql://<dbname>.turso.io?authToken=<authtoken>"
export LEMMY_USER="<username>"
export LEMMY_PASSWORD="<password>"
78 changes: 71 additions & 7 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,30 @@
name: Go

on:
schedule:
- cron: '29 0 * * *'
push:
branches: [ "main" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]

# The API requires write permission on the repository to submit coverage reports
permissions:
contents: write
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}

jobs:

build:
checks:
runs-on: ubuntu-latest
# The API requires write permission on the repository to submit coverage reports
permissions:
contents: write
checks: write
pull-requests: write
steps:
- uses: actions/checkout@v4

Expand All @@ -31,9 +42,6 @@ jobs:
- name: Lint
run: gofmt -l -e ./

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...

Expand All @@ -48,3 +56,59 @@ jobs:
add-comment: true
# One or more regular expressions matching filenames to exclude from coverage statistics (e.g. for generated Go files)
#ignore-pattern:

build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21.4'

- name: Build
run: go build -v cmd/federation.go

# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Binaries for programs and plugins
/federation
*.exe
*.exe~
*.dll
Expand Down
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM golang:1.21.4-bullseye

COPY federation /app/

EXPOSE 8080

ENTRYPOINT [ "/app/federation" ]
11 changes: 0 additions & 11 deletions cmd/db/migration/1_create_users.sql

This file was deleted.

Loading

0 comments on commit bdabbbf

Please sign in to comment.