Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Test branch for feature limits #275

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
context: ./
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/drive-server-wip:${{ github.sha }}
tags: ${{ secrets.DOCKERHUB_USERNAME }}/drive-server-wip:${{ github.sha }},${{ secrets.DOCKERHUB_USERNAME }}/drive-server-wip:latest
deploy:
needs: build
runs-on: ubuntu-latest
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/build-and-publish-dev-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build & Publish Stable Preview
on:
push:
branches: ["master"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check Out Repo
uses: actions/checkout@v2
with:
registry-url: 'https://npm.pkg.github.com'
- run: echo "registry=https://registry.yarnpkg.com/" > .npmrc
- run: echo "@internxt:registry=https://npm.pkg.github.com" >> .npmrc
# You cannot read packages from other private repos with GITHUB_TOKEN
# You have to use a PAT instead https://github.com/actions/setup-node/issues/49
- run: echo //npm.pkg.github.com/:_authToken=${{ secrets.PERSONAL_ACCESS_TOKEN }} >> .npmrc
- run: echo "always-auth=true" >> .npmrc
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and push to drive-server-wip
uses: docker/build-push-action@v2
with:
context: ./
file: ./development.Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/drive-server-wip-dev:${{ github.sha }}
dispatch_update_preview_image:
needs: build
runs-on: ubuntu-latest
steps:
- name: Dispatch Update Preview Image Command
uses: myrotvorets/[email protected]
with:
token: ${{ secrets.PAT }}
repo: internxt/environments
type: update-preview-image-command
payload: |
{
"image": "${{ secrets.DOCKERHUB_USERNAME }}/drive-server-wip",
"newImage": "${{ secrets.DOCKERHUB_USERNAME }}/drive-server-wip-dev",
"newTag": "${{ github.sha }}"
}
68 changes: 0 additions & 68 deletions .github/workflows/deploy-feature.yml

This file was deleted.

111 changes: 111 additions & 0 deletions .github/workflows/deploy-preview-feature.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: Deploy PR Preview
on:
pull_request:
types: [opened, reopened, synchronize]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check Out Repo
uses: actions/checkout@v2
with:
registry-url: 'https://npm.pkg.github.com'
- run: echo "registry=https://registry.yarnpkg.com/" > .npmrc
- run: echo "@internxt:registry=https://npm.pkg.github.com" >> .npmrc
# You cannot read packages from other private repos with GITHUB_TOKEN
# You have to use a PAT instead https://github.com/actions/setup-node/issues/49
- run: echo //npm.pkg.github.com/:_authToken=${{ secrets.PERSONAL_ACCESS_TOKEN }} >> .npmrc
- run: echo "always-auth=true" >> .npmrc
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Build and push to drive-server-wip
uses: docker/build-push-action@v2
with:
context: ./
file: ./development.Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/drive-server-wip-dev:preview-${{ github.event.number }}-${{ github.event.pull_request.head.sha }}
add_preview_label:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions-ecosystem/action-add-labels@v1
with:
labels: |
preview
dispatch_update_deployment:
needs: add_preview_label
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'deployed') }}
steps:
- name: Dispatch Update Preview Repository Command
uses: myrotvorets/[email protected]
with:
token: ${{ secrets.PAT }}
repo: internxt/environments
type: update-preview-command
payload: |
{
"github": {
"payload": {
"repository": {
"name": "${{ github.event.repository.name }}",
"full_name": "${{ github.event.repository.full_name }}"
},
"issue": {
"number": ${{ github.event.number }},
"labels": ${{ toJSON(github.event.pull_request.labels) }}
}
}
},
"slash_command": {
"args": {
"named": {
"deployment": "${{ github.event.repository.name }}",
"tag": "preview-${{ github.event.number }}-${{ github.event.pull_request.head.sha }}",
"imageSuffix": "-dev"
}
}
}
}
dispatch_check_deployment:
needs: add_preview_label
runs-on: ubuntu-latest
steps:
- name: Dispatch Check Preview Repository Command
uses: myrotvorets/[email protected]
with:
token: ${{ secrets.PAT }}
repo: internxt/environments
type: check-preview-command
payload: |
{
"github": {
"payload": {
"repository": {
"name": "${{ github.event.repository.name }}",
"full_name": "${{ github.event.repository.full_name }}",
"html_url": "${{ github.event.repository.html_url }}"
},
"issue": {
"number": ${{ github.event.number }},
"labels": ${{ toJSON(github.event.pull_request.labels) }},
"pull_request": {
"html_url": "${{ github.event.pull_request.html_url }}"
}
}
}
},
"slash_command": {
"args": {
"named": {
"notify": "true"
}
}
}
}
27 changes: 27 additions & 0 deletions .github/workflows/dispatch-cleanup-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Clean Up PR Preview
on:
pull_request:
types: [closed]
jobs:
dispatch_cleanup_deployment:
runs-on: ubuntu-latest
steps:
- name: Dispatch Cleanup Preview Repository Command
uses: myrotvorets/[email protected]
with:
token: ${{ secrets.PAT }}
repo: internxt/environments
type: cleanup-preview-command
payload: |
{
"github": {
"payload": {
"repository": {
"name": "${{ github.event.repository.name }}"
},
"issue": {
"number": ${{ github.event.number }}
}
}
}
}
45 changes: 45 additions & 0 deletions migrations/20240306175726-convert-gb-to-bytes-limits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
'use strict';

module.exports = {
async up(queryInterface, Sequelize) {
const convertGbToBytes = (gbValue) => gbValue * 1024 * 1024 * 1024;

const maxFileUploadSizeLimits = await queryInterface.sequelize.query(
"SELECT id, value FROM limits WHERE label = 'max-file-upload-size'",
{ type: Sequelize.QueryTypes.SELECT },
);

for (const limit of maxFileUploadSizeLimits) {
const bytesValue = convertGbToBytes(parseInt(limit.value)).toString();

await queryInterface.sequelize.query(
'UPDATE limits SET value = :bytesValue WHERE id = :id',
{
replacements: { bytesValue, id: limit.id },
type: Sequelize.QueryTypes.UPDATE,
},
);
}
},

async down(queryInterface, Sequelize) {
const convertBytesToGB = (gbValue) => gbValue / 1024 / 1024 / 1024;

const maxFileUploadSizeLimits = await queryInterface.sequelize.query(
"SELECT id, value FROM limits WHERE label = 'max-file-upload-size'",
{ type: Sequelize.QueryTypes.SELECT },
);

for (const limit of maxFileUploadSizeLimits) {
const bytesValue = convertBytesToGB(parseInt(limit.value)).toString();

await queryInterface.sequelize.query(
'UPDATE limits SET value = :bytesValue WHERE id = :id',
{
replacements: { bytesValue, id: limit.id },
type: Sequelize.QueryTypes.UPDATE,
},
);
}
},
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"@nestjs/jwt": "^10.2.0",
"@nestjs/passport": "^10.0.2",
"@nestjs/platform-express": "^10.2.8",
"@nestjs/schedule": "^4.0.1",
"@nestjs/sequelize": "^10.0.0",
"@nestjs/swagger": "^7.1.16",
"@nestjs/throttler": "^5.0.1",
Expand Down
23 changes: 21 additions & 2 deletions seeders/20240227151157-add-paid-plans-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,28 @@ module.exports = {
];

for (let plan of plans) {
const planAlreadyMapped = await queryInterface.sequelize.query(
`SELECT id FROM paid_plans WHERE plan_id = :planId LIMIT 1`,
{
replacements: {
planId: plan.planId,
},
type: Sequelize.QueryTypes.SELECT,
},
);

if (planAlreadyMapped.length > 0) {
continue;
}

const tiers = await queryInterface.sequelize.query(
`SELECT id FROM tiers WHERE label = '${plan.name}' LIMIT 1`,
{ type: Sequelize.QueryTypes.SELECT },
`SELECT id FROM tiers WHERE label = :label LIMIT 1`,
{
replacements: {
label: plan.name,
},
type: Sequelize.QueryTypes.SELECT,
},
);

if (tiers.length > 0) {
Expand Down
Loading
Loading