Skip to content

Commit

Permalink
Merge pull request #396 from pagopa/develop
Browse files Browse the repository at this point in the history
feat: Promote to PROD
  • Loading branch information
lucaconsalvi authored May 6, 2024
2 parents 5832a15 + 091a531 commit b3b20fc
Show file tree
Hide file tree
Showing 42 changed files with 544 additions and 219 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
steps:
# Please look up the latest version from
# https://github.com/amannn/action-semantic-pull-request/releases
- uses: amannn/action-semantic-pull-request@c3cd5d1ea3580753008872425915e343e351ab54 #v5.2.0
- uses: amannn/action-semantic-pull-request@e9fabac35e210fea40ca5b14c0da95a099eff26f #v5.4.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
steps:
- name: Checkout
id: checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 #v3.6.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
persist-credentials: false
fetch-depth: 0
Expand All @@ -24,19 +24,19 @@ jobs:
uses: docker/setup-qemu-action@68827325e0b33c7199eb31dd4e31fbe9023e06e3 #v3.0.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 #v3.0.0
uses: docker/setup-buildx-action@d70bba72b1f3fd22344832f00baa16ece964efeb #v3.3.0

- name: Log in to the Container registry
id: docker_login
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d #v3.0.0
uses: docker/login-action@e92390c5fb421da1463c202d546fed0ec5c39f20 #v3.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.BOT_WRITE_PACKAGE_TOKEN }}

- name: Build and push Docker image
id: docker_build_push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 #v5.0.0
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 #v5.3.0
with:
context: .
push: true
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 #v3.6.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
persist-credentials: false
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@5e21ff4d9bc1a8cf6de233a3057d20ec6b3fb69d #v3.8.1
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 #v4.0.2
with:
node-version: 20
scope: 'cycjimmy'
- name: Release
id: sem-release
uses: cycjimmy/semantic-release-action@61680d0e9b02ff86f5648ade99e01be17f0260a4 #v4.0.0
uses: cycjimmy/semantic-release-action@cb425203a562475bca039ba4dbf90c7f9ac790f4 #v4.1.0
with:
extra_plugins: |
semantic-release/release-notes-generator#c466b7165be2a0e5988676174e4bc244c991d669 #v11.0.7
semantic-release/release-notes-generator#148d97c53d42617d661905eb12166cb1438f0fba #v13.0.0
semantic-release/git#3e934d45f97fd07a63617c0fc098c9ed3e67d97a #v10.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/scan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ jobs:
CVE_MEDIUM: ${{env.CVE_MEDIUM}}
steps:
- name: Checkout the code
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 #v3.6.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
- name: Build the Docker image
run: docker build . --file ${{ env.DOCKERFILE }} --tag localbuild/testimage:latest
- name: Run the Trivy scan action itself with GitHub Advanced Security code scanning integration enabled
id: scan
uses: aquasecurity/trivy-action@fbd16365eb88e12433951383f5e99bd901fc618f #v0.12.0
uses: aquasecurity/trivy-action@d710430a6722f083d3b36b8339ff66b32f22ee55 #v0.19.0
with:
image-ref: "localbuild/testimage:latest"
format: 'sarif'
output: 'results.sarif'
- name: Upload Anchore Scan Report
uses: github/codeql-action/upload-sarif@6c089f53dd51dc3fc7e599c3cb5356453a52ca9e #v2.20.0
uses: github/codeql-action/upload-sarif@99c9897648dded3fe63d6f328c46089dd57735ca #codeql bundle v2.17.0
with:
sarif_file: 'results.sarif'
- name: CVE Description escaped extraction and print
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/send-notification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
steps:
- name: Send notification to Slack
id: slack
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 #v1.24.0
uses: slackapi/slack-github-action@6c661ce58804a1a20f6dc5fbee7f0381b469e001 #v1.25.0
with:
payload: |
{
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/upload-jar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
steps:
- name: Checkout
id: checkout
uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 #v3.6.0
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 #v4.1.1
with:
persist-credentials: false
fetch-depth: 0

- uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 #v3.13.0
- uses: actions/setup-java@99b8673ff64fbf99d8d325f52d9a5bdedb8483e9 #v4.2.1
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
Expand Down
4 changes: 2 additions & 2 deletions api/batch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<parent>
<artifactId>rtd-ms-transaction-filter-api</artifactId>
<groupId>it.gov.pagopa.rtd.ms.transaction_filter.api</groupId>
<version>2.1.2</version>
<version>2.2.0</version>
</parent>

<artifactId>rtd-ms-transaction-filter-api-batch</artifactId>
<version>2.1.2</version>
<version>2.2.0</version>

<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
@NotNull
@NotBlank
@Size(min = 2, max = 2)
@Pattern(regexp = "\\d{2}")
@Pattern(regexp = "00|01")
String operationType;

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
@NotNull
@NotBlank
@Size(min = 2, max = 2)
@Pattern(regexp = "\\d{2}")
@Pattern(regexp = "00|01")
String operationType;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,16 @@
import org.springframework.batch.item.file.FlatFileItemWriter;
import org.springframework.batch.item.file.LineMapper;
import org.springframework.batch.item.file.MultiResourceItemWriter;
import org.springframework.batch.item.file.builder.FlatFileItemWriterBuilder;
import org.springframework.batch.item.file.builder.MultiResourceItemWriterBuilder;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.transform.BeanWrapperFieldExtractor;
import org.springframework.batch.item.file.transform.DelimitedLineAggregator;
import org.springframework.batch.item.file.transform.DelimitedLineTokenizer;
import org.springframework.batch.item.file.transform.LineAggregator;
import org.springframework.batch.item.file.transform.LineTokenizer;
import org.springframework.batch.item.json.JacksonJsonObjectMarshaller;
import org.springframework.batch.item.json.JsonFileItemWriter;
import org.springframework.batch.item.json.builder.JsonFileItemWriterBuilder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand Down Expand Up @@ -165,8 +167,6 @@ public class TransactionFilterStep {
"senderCode", "operationType", "circuitType", "pan", "trxDate", "idTrxAcquirer",
"idTrxIssuer", "correlationId", "amount", "amountCurrency", "acquirerId", "merchantId",
"terminalId", "bin", "mcc", "fiscalCode", "vat", "posType", "par"};
private static final String[] REPORT_CSV_FIELDS = new String[]{
"name", "status", "size", "transmissionDate"};
private static final String CSV_DELIMITER = ";";
private static final String DATE_FORMAT_FOR_FILENAME = "yyyyMMddHHmmssSSS";

Expand Down Expand Up @@ -261,20 +261,6 @@ public LineAggregator<AdeTransactionsAggregate> adeTransactionsAggregateLineAggr
return delimitedLineAggregator;
}

/**
* Composes CSV lines from file report model.
* @return a line aggregator
*/
@Bean
public LineAggregator<FileMetadata> fileReportLineAggregator() {
BeanWrapperFieldExtractor<FileMetadata> extractor = new BeanWrapperFieldExtractor<>();
extractor.setNames(REPORT_CSV_FIELDS);
DelimitedLineAggregator<FileMetadata> delimitedLineAggregator = new DelimitedLineAggregator<>();
delimitedLineAggregator.setDelimiter(CSV_DELIMITER);
delimitedLineAggregator.setFieldExtractor(extractor);
return delimitedLineAggregator;
}

/**
* Builds a MultiResourceItemWriter for filtered transactions.
* Remember MultiResourceItemWriter is not thread safe.
Expand Down Expand Up @@ -515,7 +501,7 @@ public FileReportItemReader fileReportReader(FileReportRestClient restClient) {
@SneakyThrows
@Bean
@StepScope
public FlatFileItemWriter<FileMetadata> fileReportWriter() {
public JsonFileItemWriter<FileMetadata> fileReportWriter() {
DateTimeFormatter fmt = DateTimeFormatter.ofPattern(DATE_FORMAT_FOR_FILENAME);
String currentDate = OffsetDateTime.now().format(fmt);

Expand All @@ -525,13 +511,12 @@ public FlatFileItemWriter<FileMetadata> fileReportWriter() {
.concat(fileReportPrefixName)
.concat("-")
.concat(currentDate)
.concat(".csv"));
.concat(".json"));

return new FlatFileItemWriterBuilder<FileMetadata>()
.name("file-report-item-writer")
return new JsonFileItemWriterBuilder<FileMetadata>()
.jsonObjectMarshaller(new JacksonJsonObjectMarshaller<>())
.resource(outputResource)
.headerCallback(writer -> writer.write(String.join(CSV_DELIMITER, REPORT_CSV_FIELDS)))
.lineAggregator(fileReportLineAggregator())
.name("file-report-item-writer")
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import it.gov.pagopa.rtd.transaction_filter.batch.model.InboundTransaction;
import it.gov.pagopa.rtd.transaction_filter.service.StoreService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.batch.item.ItemProcessor;

Expand All @@ -15,7 +14,6 @@
* to be mapped into a normalized version defined as instances of Transaction
*/

@Slf4j
@RequiredArgsConstructor
public class InboundTransactionItemProcessor implements ItemProcessor<InboundTransaction, InboundTransaction> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
import it.gov.pagopa.rtd.transaction_filter.service.store.AggregationKey;
import it.gov.pagopa.rtd.transaction_filter.service.StoreService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.item.ItemProcessor;

/**
* ItemProcessor responsible for creating aggregates models suited for CSV
* writing from the previously in-memory aggregated data.
*/
@Slf4j
@RequiredArgsConstructor
public class TransactionAggregationWriterProcessor implements ItemProcessor<AggregationKey, AdeTransactionsAggregate> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.io.IOException;
import java.util.Collection;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
Expand All @@ -17,7 +16,6 @@
* Tasklet responsible for Sender Code uniqueness enforcing
*/
@Data
@Slf4j
public class EnforceSenderCodeUniquenessTasklet implements Tasklet {

private StoreService storeService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import it.gov.pagopa.rtd.transaction_filter.service.TransactionWriterService;
import java.io.IOException;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.core.StepContribution;
import org.springframework.batch.core.scope.context.ChunkContext;
import org.springframework.batch.core.step.tasklet.Tasklet;
Expand All @@ -24,7 +23,6 @@
* but named differently will be processed twice look at the TransactionChecksumTasklet.
*/
@Data
@Slf4j
public class PreventReprocessingFilenameAlreadySeenTasklet implements Tasklet {

private StoreService storeService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import it.gov.pagopa.rtd.transaction_filter.service.StoreService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils;
import org.springframework.batch.item.Chunk;
import org.springframework.batch.item.ItemWriter;
Expand All @@ -11,7 +10,6 @@
* Implementation of {@link ItemWriter}, to be used for read/processed Transaction files
*/

@Slf4j
@RequiredArgsConstructor
public class HpanWriter implements ItemWriter<String> {

Expand Down
Loading

0 comments on commit b3b20fc

Please sign in to comment.