From 0b37f7463627ab8eaf457c442d5e52b26e248083 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 5 Mar 2024 16:33:20 +0530 Subject: [PATCH 1/4] Add museum lint action --- .github/workflows/auth-lint.yml | 10 ++++------ .github/workflows/mobile-lint.yml | 10 ++++------ .github/workflows/server-lint.yml | 33 +++++++++++++++++++++++++++++++ .github/workflows/web-lint.yml | 9 +++++++-- server/.github/workflows/pr.yml | 21 -------------------- 5 files changed, 48 insertions(+), 35 deletions(-) create mode 100644 .github/workflows/server-lint.yml delete mode 100644 server/.github/workflows/pr.yml diff --git a/.github/workflows/auth-lint.yml b/.github/workflows/auth-lint.yml index 68fc516439..242d9ba182 100644 --- a/.github/workflows/auth-lint.yml +++ b/.github/workflows/auth-lint.yml @@ -17,20 +17,18 @@ jobs: run: working-directory: auth steps: - # Checkout our code, including submodules - - uses: actions/checkout@v4 + - name: Checkout code and submodules + uses: actions/checkout@v4 with: submodules: recursive - # Install Flutter - - uses: subosito/flutter-action@v2 + - name: Install Flutter + uses: subosito/flutter-action@v2 with: channel: "stable" flutter-version: "3.13.4" cache: true - # Install dependencies - run: flutter pub get - # Lint - run: flutter analyze --no-fatal-infos diff --git a/.github/workflows/mobile-lint.yml b/.github/workflows/mobile-lint.yml index 2f5b332af6..e38864c4e8 100644 --- a/.github/workflows/mobile-lint.yml +++ b/.github/workflows/mobile-lint.yml @@ -17,20 +17,18 @@ jobs: run: working-directory: mobile steps: - # Checkout our code, including submodules - - uses: actions/checkout@v4 + - name: Checkout code and submodules + uses: actions/checkout@v4 with: submodules: recursive - # Install Flutter - - uses: subosito/flutter-action@v2 + - name: Install Flutter + uses: subosito/flutter-action@v2 with: channel: "stable" flutter-version: "3.13.4" cache: true - # Install dependencies - run: flutter pub get - # Lint - run: flutter analyze --no-fatal-infos diff --git a/.github/workflows/server-lint.yml b/.github/workflows/server-lint.yml new file mode 100644 index 0000000000..eba5969414 --- /dev/null +++ b/.github/workflows/server-lint.yml @@ -0,0 +1,33 @@ +name: "Lint (server)" + +on: + # Run on every push (this also covers pull requests) + push: + # See: [Note: Specify branch when specifying a path filter] + branches: ["**"] + # Only run if something changes in these paths + paths: + - "server/**" + - ".github/workflows/server-lint.yml" + +jobs: + lint: + runs-on: ubuntu-latest + defaults: + run: + working-directory: server + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup go + uses: actions/setup-go@v5 + with: + go-version-file: "go.mod" + cache: true + + - name: Install dependencies + run: sudo apt-get update && sudo apt-get install libsodium-dev + + - name: Lint + run: "./scripts/lint.sh" diff --git a/.github/workflows/web-lint.yml b/.github/workflows/web-lint.yml index 12c07c8697..a905069f67 100644 --- a/.github/workflows/web-lint.yml +++ b/.github/workflows/web-lint.yml @@ -26,11 +26,16 @@ jobs: run: working-directory: web steps: - - uses: actions/checkout@v4 - - uses: actions/setup-node@v4 + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup node and enable yarn caching + uses: actions/setup-node@v4 with: node-version: 20 cache: "yarn" cache-dependency-path: "web/yarn.lock" + - run: yarn install + - run: yarn lint diff --git a/server/.github/workflows/pr.yml b/server/.github/workflows/pr.yml deleted file mode 100644 index 59ddb5fd6a..0000000000 --- a/server/.github/workflows/pr.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: Code quality - -on: - # Enable manual run - workflow_dispatch: - # Run on every push; this also covers pull requests - push: - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version-file: "go.mod" - cache: true - - run: sudo apt-get update && sudo apt-get install libsodium-dev - - run: - "./scripts/lint.sh" - # - run: "go test ./..." From 3cad79dfa929f135c5d8e3e341ef3576afbf3433 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 5 Mar 2024 16:39:11 +0530 Subject: [PATCH 2/4] Add museum release action --- .../workflows/server-release.yml | 10 ++----- server/.github/workflows/dev-ci.yml | 28 ------------------- 2 files changed, 2 insertions(+), 36 deletions(-) rename server/.github/workflows/prod-ci.yml => .github/workflows/server-release.yml (70%) delete mode 100644 server/.github/workflows/dev-ci.yml diff --git a/server/.github/workflows/prod-ci.yml b/.github/workflows/server-release.yml similarity index 70% rename from server/.github/workflows/prod-ci.yml rename to .github/workflows/server-release.yml index 791e5218ce..d3007e9410 100644 --- a/server/.github/workflows/prod-ci.yml +++ b/.github/workflows/server-release.yml @@ -1,16 +1,10 @@ -name: Prod CI +name: "Release (server)" on: - workflow_dispatch: - # Enable manual run - push: - # Sequence of patterns matched against refs/tags - tags: - - "v*" # Push events to matching v*, i.e. v4.2.0 + workflow_dispatch: # Run manually jobs: build: - # This job will run on ubuntu virtual machine runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/server/.github/workflows/dev-ci.yml b/server/.github/workflows/dev-ci.yml deleted file mode 100644 index 8900f53694..0000000000 --- a/server/.github/workflows/dev-ci.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Dev CI - -on: - workflow_dispatch: - # Enable manual run - push: - # Sequence of patterns matched against refs/tags - tags: - - "v*" # Push events to matching v*, i.e. v4.2.0 - -jobs: - build: - # This job will run on ubuntu virtual machine - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - name: Check out code - - - uses: mr-smithers-excellent/docker-build-push@v6 - name: Build & Push - with: - image: ente/museum-dev - registry: rg.fr-par.scw.cloud - enableBuildKit: true - buildArgs: GIT_COMMIT=${GITHUB_SHA} - tags: ${GITHUB_SHA}, latest - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} From 9127d9540c157a051d34cf36d6725b87cc8c944e Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 5 Mar 2024 16:45:42 +0530 Subject: [PATCH 3/4] Handle subdir --- .github/workflows/server-lint.yml | 2 +- .github/workflows/server-release.yml | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/server-lint.yml b/.github/workflows/server-lint.yml index eba5969414..e23036a6ed 100644 --- a/.github/workflows/server-lint.yml +++ b/.github/workflows/server-lint.yml @@ -23,7 +23,7 @@ jobs: - name: Setup go uses: actions/setup-go@v5 with: - go-version-file: "go.mod" + go-version-file: "server/go.mod" cache: true - name: Install dependencies diff --git a/.github/workflows/server-release.yml b/.github/workflows/server-release.yml index d3007e9410..8f0281951a 100644 --- a/.github/workflows/server-release.yml +++ b/.github/workflows/server-release.yml @@ -13,6 +13,8 @@ jobs: - uses: mr-smithers-excellent/docker-build-push@v6 name: Build & Push with: + dockerfile: server/Dockerfile + directory: server image: ente/museum-prod registry: rg.fr-par.scw.cloud enableBuildKit: true From 795c2baf0f917ef56b595acb41d1e80e83e3feb6 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 5 Mar 2024 16:53:15 +0530 Subject: [PATCH 4/4] Fix lint --- server/pkg/repo/queue.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/pkg/repo/queue.go b/server/pkg/repo/queue.go index 67f54c572b..1f706aa88d 100644 --- a/server/pkg/repo/queue.go +++ b/server/pkg/repo/queue.go @@ -48,7 +48,7 @@ type QueueItem struct { // InsertItem adds entry in the queue with given queueName and item. If entry already exists, it's no-op func (repo *QueueRepository) InsertItem(ctx context.Context, queueName string, item string) error { - _, err := repo.DB.ExecContext(ctx, `INSERT INTO queue(queue_name, item) VALUES($1, $2) + _, err := repo.DB.ExecContext(ctx, `INSERT INTO queue(queue_name, item) VALUES($1, $2) ON CONFLICT (queue_name, item) DO NOTHING`, queueName, item) if err != nil { return stacktrace.Propagate(err, "") @@ -83,7 +83,7 @@ func (repo *QueueRepository) RequeueItem(ctx context.Context, queueName string, if count == 0 { return fmt.Errorf("no item found with queueID: %d for queue %s", queueID, queueName) } - logrus.Info("Re-queued %d item with queueID: %d for queue %s", count, queueID, queueName) + logrus.Infof("Re-queued %d item with queueID: %d for queue %s", count, queueID, queueName) return nil }