Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
4ff36cf
move compress image to the new ownership, remove redundant github act…
selul Sep 1, 2021
3294826
[skip ci] adds back docker build workflow
selul Sep 2, 2021
fd78e67
Bump @babel/core from 7.15.0 to 7.15.4 in /Web
dependabot[bot] Sep 3, 2021
037d16f
Bump Magick.NET-Q16-AnyCPU from 8.2.1 to 8.3.0
dependabot[bot] Sep 6, 2021
5bc8cfd
Bump @babel/core from 7.15.4 to 7.15.5 in /Web
dependabot[bot] Sep 6, 2021
99cd73c
Bump axios from 0.21.1 to 0.21.2 in /Web
dependabot[bot] Sep 6, 2021
81cbaa4
Bump MSTest.TestFramework from 2.2.6 to 2.2.7
dependabot[bot] Sep 6, 2021
6fbc12f
Bump MSTest.TestAdapter from 2.2.6 to 2.2.7
dependabot[bot] Sep 6, 2021
03f120b
Bump axios from 0.21.2 to 0.21.4 in /Web
dependabot[bot] Sep 7, 2021
8730891
Bump Magick.NET-Q16-AnyCPU from 8.3.0 to 8.3.1
dependabot[bot] Sep 14, 2021
3eb4318
Bump Microsoft.Azure.WebJobs.Extensions.Storage from 4.0.4 to 4.0.5
dependabot[bot] Sep 20, 2021
3d08dd2
Bump Magick.NET-Q16-AnyCPU from 8.3.1 to 8.3.2
dependabot[bot] Sep 21, 2021
5655ed0
Bump vue-loader from 16.5.0 to 16.6.0 in /Web
dependabot[bot] Sep 21, 2021
fa08d7b
chore: updated pull request template
GrigoreMihai Sep 22, 2021
3dda85c
Bump vue-loader from 16.6.0 to 16.7.0 in /Web
dependabot[bot] Sep 22, 2021
dd28d40
chore: updated urls in repo and issues
GrigoreMihai Sep 23, 2021
e9a94cd
Merge pull request #1009 from imgbot/update_pull_request_template
GrigoreMihai Sep 23, 2021
37321a8
Bump vue-loader from 16.7.0 to 16.8.1 in /Web
dependabot[bot] Sep 23, 2021
02de020
fix: changed dotnet image version
GrigoreMihai Sep 23, 2021
0e31dfe
Merge pull request #1011 from imgbot/fix/docker_image
GrigoreMihai Sep 24, 2021
a4bdb06
chore: added test github action
GrigoreMihai Sep 24, 2021
d8e820b
Merge pull request #1012 from imgbot/feat/github_actions_dotnet_test
GrigoreMihai Sep 27, 2021
4d5e7bb
build(deps-dev): bump autoprefixer from 9.8.6 to 9.8.7 in /Web
dependabot[bot] Sep 27, 2021
5ca4176
chore: started to add a plan for which to count the repos
GrigoreMihai Sep 27, 2021
459a613
feat: added plan with limited repos number
GrigoreMihai Sep 28, 2021
5b8b3ae
fix: marketplace update reseting some fields to default values
GrigoreMihai Sep 29, 2021
875694b
chore: added functionalities for limited repos plan
GrigoreMihai Oct 1, 2021
c346513
chore: using map for defining plans and number of private repositories
GrigoreMihai Oct 4, 2021
a9724e1
chore: sync master
GrigoreMihai Oct 4, 2021
6097d01
chore: removed not needed logs
GrigoreMihai Oct 4, 2021
c276b8f
chore: added changes for language level usage
GrigoreMihai Oct 4, 2021
8f8d8f4
chore: removed redundand code changes
GrigoreMihai Oct 4, 2021
4145aae
fix: issues with public repos changing private repos limits
GrigoreMihai Oct 5, 2021
aef4261
chore: removed redundat libraries include
GrigoreMihai Oct 5, 2021
e86c478
fix: repository optimization on push
GrigoreMihai Oct 14, 2021
d4ec2b4
chore: added a part of configurable pr code
GrigoreMihai Oct 14, 2021
138a671
chore: added the changes for the configurable pr
GrigoreMihai Oct 15, 2021
1bba836
chore: finished configurable pr functionality and added documentation
GrigoreMihai Oct 18, 2021
e2f5052
fix: small bugs with the added plans
GrigoreMihai Oct 19, 2021
0de71d1
chore: added null check for table result
GrigoreMihai Oct 19, 2021
8b0784a
chore: added plans
GrigoreMihai Oct 19, 2021
1411d56
Merge pull request #1017 from imgbot/feat/count_private_repository_plan
GrigoreMihai Oct 19, 2021
5bae9c7
build(deps-dev): bump axios from 0.21.4 to 0.23.0 in /Web
dependabot[bot] Oct 19, 2021
9b84cdc
build(deps): bump Portable.BouncyCastle from 1.8.10 to 1.9.0
dependabot[bot] Oct 19, 2021
d551aec
build(deps-dev): bump vue-loader from 15.9.7 to 15.9.8 in /Web
dependabot[bot] Oct 20, 2021
c455cc5
chore: added plans
GrigoreMihai Oct 20, 2021
c1e37b0
Merge pull request #1037 from imgbot/feat/count_private_repository_plan
GrigoreMihai Oct 20, 2021
d84e596
build(deps-dev): bump axios from 0.23.0 to 0.24.0 in /Web
dependabot[bot] Oct 26, 2021
79997b8
build(deps): bump Magick.NET-Q16-AnyCPU from 8.3.2 to 8.4.0
dependabot[bot] Oct 29, 2021
341195a
build(deps): bump Magick.NET-Q16-AnyCPU from 8.4.0 to 8.5.0
dependabot[bot] Dec 14, 2021
e510658
build(deps): bump Magick.NET-Q16-AnyCPU from 8.5.0 to 8.6.1
dependabot[bot] Jan 17, 2022
f5b4136
build(deps): bump Magick.NET-Q16-AnyCPU from 8.6.1 to 9.0.0
dependabot[bot] Jan 24, 2022
d84f46e
build(deps): bump Magick.NET-Q16-AnyCPU from 9.0.0 to 9.1.0
dependabot[bot] Feb 7, 2022
cd3ee08
build(deps): bump Magick.NET-Q16-AnyCPU from 9.1.0 to 9.1.1
dependabot[bot] Feb 8, 2022
04eca3f
build(deps): bump Magick.NET-Q16-AnyCPU from 9.1.1 to 9.1.2
dependabot[bot] Feb 14, 2022
e4c565d
build(deps): bump Magick.NET-Q16-AnyCPU from 9.1.2 to 10.0.0
dependabot[bot] Feb 22, 2022
c9c4f59
fix: deleting local repository clone after optimization
GrigoreMihai Feb 23, 2022
4a48515
Merge pull request #1116 from imgbot/fix/clean_memory
GrigoreMihai Feb 23, 2022
5020c66
build(deps): bump Magick.NET-Q16-AnyCPU from 10.0.0 to 10.1.0
dependabot[bot] Mar 7, 2022
8bca6d0
chore: added backup queue for purchases
GrigoreMihai Mar 22, 2022
c30b009
chore: adjusted compress function timeout and batch size
GrigoreMihai Mar 22, 2022
d55acda
chore: added latest changes for backup queue
GrigoreMihai Mar 23, 2022
9901d84
chore: updated plans
GrigoreMihai Mar 23, 2022
957f299
chore: small inteface updates
GrigoreMihai Mar 23, 2022
17253c0
chore: updated tests
GrigoreMihai Mar 23, 2022
e63879c
chore: modified compress batch
GrigoreMihai Mar 24, 2022
b1cd054
Merge pull request #1129 from imgbot/backup_queue
GrigoreMihai Mar 24, 2022
89d7d94
build(deps): bump Magick.NET-Q16-AnyCPU from 10.1.0 to 11.0.0
dependabot[bot] Mar 28, 2022
7b70767
build(deps): bump Magick.NET-Q16-AnyCPU from 11.0.0 to 11.1.0
dependabot[bot] Apr 8, 2022
e77d6d0
build(deps): bump Magick.NET-Q16-AnyCPU from 11.1.0 to 11.1.2
dependabot[bot] May 16, 2022
c2cfffb
build(deps): bump Magick.NET-Q16-AnyCPU from 11.1.2 to 11.2.0
dependabot[bot] Jun 13, 2022
5476206
chore: added backup message for cancelled subscription
GrigoreMihai Jun 20, 2022
b659e0d
chore: updated payload to include BillingCycle
GrigoreMihai Jun 21, 2022
b0b6c46
Merge pull request #1175 from imgbot/backup_queue_update
GrigoreMihai Jun 21, 2022
f70100f
build(deps): bump Magick.NET-Q16-AnyCPU from 11.2.0 to 11.2.1
dependabot[bot] Jun 22, 2022
f1a44bb
build(deps): bump Magick.NET-Q16-AnyCPU from 11.2.1 to 11.3.0
dependabot[bot] Jul 12, 2022
3598e45
chore: added sender email and organization email to backup queue
GrigoreMihai Jul 28, 2022
da9c090
chore: lint code
GrigoreMihai Jul 29, 2022
e5abd60
Merge pull request #1197 from imgbot/backup_improvements
GrigoreMihai Jul 29, 2022
0e15f09
build(deps): bump Magick.NET-Q16-AnyCPU from 11.3.0 to 12.0.1
dependabot[bot] Aug 8, 2022
47ffd93
(GitHub CI) Bump actions/checkout version in workflows (#1188)
ArjunSharda Aug 14, 2022
36f30b2
Corrected the dependabot.yml configuration file.
dlemstra Aug 14, 2022
de84c52
chore: reverted Magick.NET version
GrigoreMihai Aug 16, 2022
7a40724
Merge pull request #1214 from imgbot/revert_magick_net
GrigoreMihai Aug 16, 2022
d6b997c
chore: increased task timeout to be greater than individual image tim…
GrigoreMihai Aug 16, 2022
9116c77
Merge pull request #1215 from imgbot/increase_timeout
GrigoreMihai Aug 16, 2022
10b090c
chore: increased compress function timeout
GrigoreMihai Aug 16, 2022
b2d0d3c
Merge pull request #1216 from imgbot/increase_timeout
GrigoreMihai Aug 16, 2022
9e4f4b8
chore: started to add sync workflow between database and git data
GrigoreMihai Oct 7, 2022
156be66
chore: finished marketplace sync update
GrigoreMihai Oct 10, 2022
cd5b1c0
chore: enabled delete for MarketplaceSync, increased newBatchThreshol…
GrigoreMihai Oct 10, 2022
fb9022a
Merge pull request #1245 from imgbot/update_marketplace_sync
GrigoreMihai Oct 10, 2022
a5b3921
chore: started compress function update
GrigoreMihai Oct 11, 2022
633a3ec
chore: manually added libgit2 library
GrigoreMihai Oct 11, 2022
a1d542f
chore: updated compress images function to net6.0
GrigoreMihai Oct 12, 2022
7e0159a
chore: updated all functions to net6.0
GrigoreMihai Oct 12, 2022
9fdb13c
chore: updated test action
GrigoreMihai Oct 12, 2022
6631e28
chore: removed redundant changes from testing
GrigoreMihai Oct 13, 2022
b0ca225
Merge pull request #1250 from imgbot/update_compress_runtime
GrigoreMihai Oct 13, 2022
10d432a
chore: increased visibility timeout for failed messages
GrigoreMihai Oct 13, 2022
3dabf9d
Merge pull request #1254 from imgbot/update_visibility_timeout
GrigoreMihai Oct 13, 2022
724e122
chore: decreased new batch threshold
GrigoreMihai Nov 11, 2022
ee5aaac
Merge pull request #1267 from imgbot/decrease_new_batch_threshold
GrigoreMihai Nov 11, 2022
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
85 changes: 5 additions & 80 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,93 +5,18 @@ updates:
schedule:
interval: daily
time: "13:00"
open-pull-requests-limit: 10
ignore:
- dependency-name: Magick.NET-Q16-AnyCPU
versions:
- 7.23.1
- 7.23.2
- 7.23.2.1
- 7.23.3
- dependency-name: MSTest.TestAdapter
versions:
- 2.2.1
- 2.2.2
- dependency-name: MSTest.TestFramework
versions:
- 2.2.1
- 2.2.2
- dependency-name: Microsoft.NET.Test.Sdk
versions:
- 16.8.3
- 16.9.1
- dependency-name: Octokit
versions:
- 0.49.0
- dependency-name: Portable.BouncyCastle
versions:
- 1.8.9
- dependency-name: Microsoft.Azure.WebJobs.Extensions.Storage
versions:
- 4.0.3
- package-ecosystem: npm
directory: "/Web"
schedule:
interval: daily
time: "13:00"
open-pull-requests-limit: 10
ignore:
- dependency-name: css-loader
versions:
- 5.0.1
- 5.0.2
- 5.1.0
- 5.1.1
- 5.1.2
- 5.1.3
- 5.1.4
- 5.2.0
- 5.2.1
- 5.2.3
- dependency-name: eslint
versions:
- 7.18.0
- 7.19.0
- 7.20.0
- 7.21.0
- 7.22.0
- 7.23.0
- 7.24.0
- dependency-name: "@babel/core"
versions:
- 7.12.10
- 7.12.13
- 7.12.16
- 7.12.17
- 7.13.1
- 7.13.10
- 7.13.14
- 7.13.15
- 7.13.8
- dependency-name: y18n
versions:
- 4.0.1
- 4.0.2
- dependency-name: grunt
versions:
- 1.3.0
- dependency-name: lodash
versions:
- 4.17.20
- package-ecosystem: docker
directory: "/"
schedule:
interval: daily
time: "13:00"
open-pull-requests-limit: 10
ignore:
- dependency-name: dotnet/core/sdk
versions:
- 3.1.405
- 3.1.406
- 3.1.407
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: daily
time: "13:00"
2 changes: 1 addition & 1 deletion .github/workflows/dockerimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build -f Dockerfile.CompressImages . -t imgbot
16 changes: 0 additions & 16 deletions .github/workflows/release.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Dotnet Tests

on:
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: [ '6.0.402' ]

steps:
- uses: actions/checkout@v3
- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v1.7.2
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --no-restore --verbosity normal
8 changes: 4 additions & 4 deletions Auth/Auth.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.24" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.3" />
</ItemGroup>
<ItemGroup>
Expand Down
9 changes: 6 additions & 3 deletions Auth/AuthFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public static async Task<HttpResponseMessage> Callback(
var mktplcResponse = await HttpClient.SendAsync(mktplcRequest);
var planDataJson = await mktplcResponse.Content.ReadAsStringAsync();
var planData = JsonConvert.DeserializeObject<PlanData[]>(planDataJson);

var eduData = new Edu();
var isStudent = false;
try
{
var eduRequest = new HttpRequestMessage(HttpMethod.Get, "https://education.github.com/api/user");
Expand All @@ -110,6 +110,10 @@ public static async Task<HttpResponseMessage> Callback(
var eduResponse = await HttpClient.SendAsync(eduRequest);
var eduDataJson = await eduResponse.Content.ReadAsStringAsync();
eduData = JsonConvert.DeserializeObject<Edu>(eduDataJson);
if (eduData != null)
{
isStudent = eduData.Student;
}
}
catch (Exception e)
{
Expand All @@ -122,9 +126,8 @@ public static async Task<HttpResponseMessage> Callback(
{
AccountType = item.account.type,
PlanId = item.plan.id,
Student = eduData.Student,
Student = isStudent,
};

await marketplaceTable.CreateIfNotExistsAsync();
await marketplaceTable.ExecuteAsync(TableOperation.InsertOrMerge(marketplaceRow));
}
Expand Down
65 changes: 60 additions & 5 deletions Auth/InstallationFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public static async Task<HttpResponseMessage> ListAsync(
x.account.avatar_url,
planId = (mktplc.Result as Common.TableModels.Marketplace)?.PlanId,
student = (mktplc.Result as Common.TableModels.Marketplace)?.Student,
allowedPrivate = (mktplc.Result as Common.TableModels.Marketplace)?.AllowedPrivate,
usedPrivate = (mktplc.Result as Common.TableModels.Marketplace)?.UsedPrivate,
};
}));

Expand Down Expand Up @@ -167,9 +169,10 @@ public static async Task<HttpResponseMessage> ListPullsAsync(

[FunctionName("RequestRepositoryCheckFunction")]
public static async Task<HttpResponseMessage> RequestRepositoryCheckAsync(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "repositories/check/{installationid}/{repositoryid}")]HttpRequestMessage req,
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "repositories/check/{installationid}/{repositoryid}/{compress?}")]HttpRequestMessage req,
string installationid,
string repositoryid)
string repositoryid,
string compress)
{
var token = req.ReadCookie("token");
if (token == null)
Expand All @@ -190,22 +193,71 @@ public static async Task<HttpResponseMessage> RequestRepositoryCheckAsync(
response.EnableCors();

var imgbotBranch = await GetImgbotBranch(repository, token);
if (imgbotBranch != null)
if (imgbotBranch != null && compress == null)
{
// branch already exists
response.SetJson(new { status = "branchexists" });
return response;
}

var shouldCompress = true;
if (compress == "false")
{
shouldCompress = false;
}

bool updateValid = true;
int? usedPrivateValue = 0;
if (compress != null && repository.@private == true)
{
updateValid = false;
var marketplaceTable = GetTable("marketplace");
var installationsData = await GetInstallationsData(token);
await Task.WhenAll(installationsData.installations.Select(async x =>
{
var mktplc = await marketplaceTable.ExecuteAsync(
TableOperation.Retrieve<Common.TableModels.Marketplace>(x.account.id.ToString(), x.account.login));

var allowedPrivate = (mktplc.Result as Common.TableModels.Marketplace)?.AllowedPrivate;
var usedPrivate = (mktplc.Result as Common.TableModels.Marketplace)?.UsedPrivate;
usedPrivateValue = usedPrivate;
if (shouldCompress)
{
if (usedPrivate < allowedPrivate || allowedPrivate == null)
{
usedPrivate++;
updateValid = true;
}
}
else
{
usedPrivate--;
updateValid = true;
}

if (updateValid == true)
{
await marketplaceTable.ExecuteAsync(TableOperation.InsertOrMerge(new Common.TableModels.Marketplace(x.account.id, x.account.login)
{
UsedPrivate = usedPrivate,
}));
usedPrivateValue = usedPrivate;
}
}));
}

await routerQueue.AddMessageAsync(new CloudQueueMessage(JsonConvert.SerializeObject(new Common.Messages.RouterMessage
{
CloneUrl = repository.html_url,
InstallationId = Convert.ToInt32(installationid),
Owner = repository.owner.login,
RepoName = repository.name,
Compress = shouldCompress,
IsPrivate = repository.@private,
Update = updateValid,
})));

response.SetJson(new { status = "OK" });
response.SetJson(new { status = "OK", usedPrivate = usedPrivateValue });
return response;
}

Expand All @@ -222,6 +274,7 @@ public static async Task<HttpResponseMessage> GetRepositorySettingsAsync(
}

var repository = await GetRepository(installationid, token, repositoryid);

if (repository == null)
{
throw new Exception("repository request mismatch");
Expand Down Expand Up @@ -308,7 +361,9 @@ private static async Task<object> RepositoryResponse(Model.Repository ghReposito
ghRepository.html_url,
ghRepository.name,
ghRepository.fork,
lastchecked = (installation.Result as Common.TableModels.Installation)?.LastChecked
lastchecked = (installation.Result as Common.TableModels.Installation)?.LastChecked,
IsPrivate = (installation.Result as Common.TableModels.Installation)?.IsPrivate,
IsOptimized = (installation.Result as Common.TableModels.Installation)?.IsOptimized
};
}

Expand Down
2 changes: 1 addition & 1 deletion Common/Common.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
40 changes: 36 additions & 4 deletions Common/KnownGitHubs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
namespace Common
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace Common
{
public static class KnownGitHubs
{
Expand All @@ -14,9 +17,38 @@ public static class KnownGitHubs

public const string BranchName = "imgbot";

/// <remarks>
/// {0} = installation_id
/// </remarks>
// <remarks>
// {0} = installation_id.
// </remarks>
public const string AccessTokensUrlFormat = "https://api.github.com/app/installations/{0}/access_tokens";

public const int SmallestLimitPaidPlan = 1;

// -1 for existing plans that include unlimited private
// -2 for old plans which also have unlimited private, that do not need marketplacesync
// int values represent the number of private repos
// the last plan we need to edit after creating it in github market place
public static readonly ReadOnlyDictionary<int, int> Plans
= new ReadOnlyDictionary<int, int>(
new Dictionary<int, int>()
{
{ 781, 0 },
{ 1749, 0 },
{ 6927, 0 },
{ 1750, -2 },
{ 2840, -2 },
{ 2841, -2 },
{ 6894, 5 },
{ 6919, 10 },
{ 6920, 20 },
{ 6921, 50 },
{ 6922, 100 },
{ 6923, 200 },
{ 7386, 1 },
{ 7387, 3 },
{ 7388, 10 },
{ 7389, 25 },
{ 7390, 100 },
});
}
}
17 changes: 17 additions & 0 deletions Common/Messages/BackupMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Common.Messages
{
public class BackupMessage
{
public int PlanId { get; set; }

public string SaleType { get; set; }

public string BillingCycle { get; set; }

public int Price { get; set; }

public string SenderEmail { get; set; }

public string OrganizationBillingEmail { get; set; }
}
}
Loading