Skip to content

Commit

Permalink
Port demo feature (#226)
Browse files Browse the repository at this point in the history
* Port demo feature

* Migrate to dotnet 8

* Fix

* Fix

* Update browserstack

* Fix

* Fix
  • Loading branch information
framebassman authored May 1, 2024
1 parent 677fe34 commit 41e5663
Show file tree
Hide file tree
Showing 24 changed files with 75 additions and 43 deletions.
4 changes: 2 additions & 2 deletions .ci/semaphore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ blocks:
- sudo apt-get install docker-compose-plugin
- docker compose version
# install dotnet core
- sudo apt-get install -y dotnet-sdk-7.0
- sudo apt-get install -y dotnet-sdk-8.0
# checkout repo
- chmod 0600 ~/.ssh/*
- checkout
Expand All @@ -37,7 +37,7 @@ blocks:
- bash ./Scripts/wait-until-app-is-deployed.sh
# run migrations
- dotnet --info
- dotnet tool install --global dotnet-ef --version 7.0.5
- dotnet tool install --global dotnet-ef --version 8.0.3
- export ASPNETCORE_ENVIRONMENT=TestMigrations; ~/.dotnet/tools/dotnet-ef database update --project Services/TicketStore.Data/TicketStore.Data.csproj --verbose
# run integration tests
- dotnet test Services/TicketStore.Api.Tests --logger "junit;LogFilePath=TestResults/report.xml" --filter Category!=DevelopmentData
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/bundlesize.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
working-directory: Services/TicketStore.Web/Client
run: |
npm install
npm run check-bundlesize
npm run build
npm run bundlesize
env:
CI: true
1 change: 1 addition & 0 deletions Deploy/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ services:
tty: true
store_proxy:
container_name: store_proxy
image: traefik:1.7
ports:
- 80:80
volumes:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
2 changes: 1 addition & 1 deletion Services/TicketStore.Api/Controllers/PaymentsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ [FromForm] String? sha1_hash
var concert = _db.Events
.AsEnumerable()
.FirstOrDefault(e =>
new LabelCalculator(_log, e).Value() == label
label.Contains(e.Artist)
);
if (concert == null)
{
Expand Down
2 changes: 1 addition & 1 deletion Services/TicketStore.Api/Dockerfile.Development
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0.203-alpine3.17
FROM mcr.microsoft.com/dotnet/sdk:8.0.203-alpine3.19-amd64
ENV DOTNET_GENERATE_ASPNET_CERTIFICATE=false
# libgdiplus-dev - for bitmap creating and pdf generation
# gcompat, libwkhtmltox.so - for pdf generation
Expand Down
4 changes: 2 additions & 2 deletions Services/TicketStore.Api/Dockerfile.Production
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0.203-alpine3.17 AS build-env
FROM mcr.microsoft.com/dotnet/sdk:8.0.203-alpine3.19-amd64 AS build-env
ENV DOTNET_GENERATE_ASPNET_CERTIFICATE=false
COPY ./Services/TicketStore.Api/ /app
COPY ./Services/TicketStore.Data/ /TicketStore.Data
WORKDIR /app
RUN dotnet restore
RUN dotnet publish -c Release -o out

FROM mcr.microsoft.com/dotnet/aspnet:7.0.5-alpine3.17
FROM mcr.microsoft.com/dotnet/aspnet:8.0.3-alpine3.19-amd64
# libgdiplus-dev - for bitmap creating and pdf generation
# gcompat, libwkhtmltox.so - for pdf generation
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public virtual String ToBase64(String origin)

private String GenerateBarcodeTask(String ticketNumber)
{
var imageUrl = $"https://www.scandit.com/wp-content/themes/scandit/barcode-generator.php?symbology=code128&value={ticketNumber}&size=200&ec=L";
var imageUrl = $"https://barcodeapi.org/api/code128/{ticketNumber}";
using (var inputStream = _client.GetStreamAsync(imageUrl).Result)
{
using (var memoryStream = new MemoryStream())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<div>
<img style="height: 100px" src="data:image/png;base64, %PICTURE%" />
<div>%NUMBER%</div>
<!-- <div>%NUMBER%</div> -->
</div>
2 changes: 1 addition & 1 deletion Services/TicketStore.Api/TicketStore.Api.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
8 changes: 7 additions & 1 deletion Services/TicketStore.Data/ApplicationContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ protected override void OnConfiguring(DbContextOptionsBuilder builder)
{
if (IsAppRunning())
{
builder.UseNpgsql(new ApplicationSettings().ConnectionString());
builder.UseNpgsql(
new ApplicationSettings().ConnectionString(),
builder =>
{
builder.EnableRetryOnFailure(5, TimeSpan.FromSeconds(10), null);
}
);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Services/TicketStore.Data/TicketStore.Data.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
26 changes: 20 additions & 6 deletions Services/TicketStore.Web/Client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions Services/TicketStore.Web/Client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@
"scripts": {
"start": "NODE_OPTIONS=--openssl-legacy-provider react-scripts start",
"build": "NODE_OPTIONS=--openssl-legacy-provider react-scripts build",
"test": "react-scripts test --env=jsdom --reporters=default --reporters=jest-junit",
"test": "NODE_OPTIONS=--openssl-legacy-provider react-scripts test --env=jsdom --reporters=default --reporters=jest-junit",
"eject": "react-scripts eject",
"bundlesize": "bundlesize",
"check-bundlesize": "react-scripts build && bundlesize"
"bundlesize": "bundlesize"
},
"eslintConfig": {
"extends": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,18 @@ function isEmpty(origin: string) {
}

export const PayButton = (props: PayButtonProps) => {
const { roubles, label, targets, yandexMoneyAccount } = props;
const { roubles, label, yandexMoneyAccount } = props;
if (roubles <= 0 || isEmpty(yandexMoneyAccount)) {
return null;
} else {
return (
<form style={{marginLeft: 'auto', marginRight: 'auto'}} method="POST" action="https://money.yandex.ru/quickpay/confirm.xml">
<form style={{marginLeft: 'auto', marginRight: 'auto'}} method="POST" action="https://yoomoney.ru/quickpay/confirm.xml">
<input type="hidden" name="receiver" value={yandexMoneyAccount} />
<input type="hidden" name="quickpay-form" value="small" />
<input type="hidden" name="need-email" value="true" />
<input type="hidden" name="quickpay-form" value="button" />
<input type="hidden" name="label" value={label} />
<input type="hidden" name="targets" value={targets} />
<input type="hidden" name="sum" value={roubles} data-type="number"></input>
<input type="hidden" name="paymentType" value="AC"/>
<input type="hidden" name="successURL" value={window.location.hostname + "/tickets/farewell"} />
<Button variant="contained" color="secondary" size="large" type="submit">Купить билет</Button>
</form>
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.button_wrapper {
text-align: center;
}

.start_button {
position: absolute;
top: 30%;
height: 320px;
width: 320px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ type Props = {

export const TurnstileOnHold = ({ onClick }: Props) => {
return (
<Button variant="contained" onClick={onClick}>
<Typography variant="h4">Начать сканировать</Typography>
</Button>
<div className="button_wrapper">
<Button variant="contained" onClick={onClick}>
<Typography variant="h4">Начать сканировать</Typography>
</Button>
</div>
)
};
2 changes: 1 addition & 1 deletion Services/TicketStore.Web/Dockerfile.Development
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0.203-alpine3.17 AS build-env
FROM mcr.microsoft.com/dotnet/sdk:8.0.203-alpine3.19-amd64 AS build-env
ENV DOTNET_GENERATE_ASPNET_CERTIFICATE=false
RUN apk add --update 'nodejs>18.14.0' 'npm>9.1.0'
# install debugger
Expand Down
4 changes: 2 additions & 2 deletions Services/TicketStore.Web/Dockerfile.Production
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0.203-alpine3.17 AS build-env
FROM mcr.microsoft.com/dotnet/sdk:8.0.203-alpine3.19-amd64 AS build-env

ARG REACT_APP_ENVIRONMENT=Production

Expand All @@ -15,7 +15,7 @@ RUN dotnet restore
RUN dotnet publish -c Release -o out


FROM mcr.microsoft.com/dotnet/aspnet:7.0.5-alpine3.17
FROM mcr.microsoft.com/dotnet/aspnet:8.0.3-alpine3.19-amd64
ENV DOTNET_GENERATE_ASPNET_CERTIFICATE=false
WORKDIR /app
COPY --from=build-env /app/out .
Expand Down
2 changes: 1 addition & 1 deletion Services/TicketStore.Web/TicketStore.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
Expand Down
12 changes: 6 additions & 6 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ stages:
displayName: 'Install Dotnet Core'
inputs:
packageType: sdk
version: 7.0.203
version: 8.0.204
- script: |
dotnet test --logger "trx;LogFileName=report.trx" --collect:"XPlat Code Coverage"
workingDirectory: $(build.sourcesDirectory)/Services/TicketStore.Api.Tests.Unit
Expand All @@ -64,7 +64,7 @@ stages:
inputs:
targetType: 'inline'
script: bash <(curl -s https://codecov.io/bash)
- task: PublishCodeCoverageResults@1
- task: PublishCodeCoverageResults@2
displayName: 'publish code coverage report to Azure Devops'
inputs:
codeCoverageTool: 'cobertura' # Options: cobertura, jaCoCo
Expand All @@ -83,7 +83,7 @@ stages:
displayName: 'Install Dotnet Core'
inputs:
packageType: sdk
version: 7.0.203
version: 8.0.204
- script: |
dotnet test --logger "trx;LogFileName=report.trx" --collect:"XPlat Code Coverage"
workingDirectory: $(build.sourcesDirectory)/Services/TicketStore.Web.Tests.Unit
Expand All @@ -107,7 +107,7 @@ stages:
inputs:
targetType: 'inline'
script: bash <(curl -s https://codecov.io/bash)
- task: PublishCodeCoverageResults@1
- task: PublishCodeCoverageResults@2
displayName: 'publish code coverage report to Azure Devops'
inputs:
codeCoverageTool: 'cobertura' # Options: cobertura, jaCoCo
Expand All @@ -126,7 +126,7 @@ stages:
displayName: 'Install Dotnet Core'
inputs:
packageType: sdk
version: 7.0.203
version: 8.0.204
- script: |
dotnet test --logger "trx;LogFileName=report.trx" --collect:"XPlat Code Coverage"
workingDirectory: $(build.sourcesDirectory)/Services/TicketStore.Data.Tests.Unit
Expand All @@ -150,7 +150,7 @@ stages:
inputs:
targetType: 'inline'
script: bash <(curl -s https://codecov.io/bash)
- task: PublishCodeCoverageResults@1
- task: PublishCodeCoverageResults@2
displayName: 'publish code coverage report to Azure Devops'
inputs:
codeCoverageTool: 'cobertura' # Options: cobertura, jaCoCo
Expand Down

0 comments on commit 41e5663

Please sign in to comment.