diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 618e0a7..9e4201c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,12 +20,17 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '22' - name: Setup Python uses: actions/setup-python@v4 with: - python-version: '3.9' + python-version: '3.11' - name: Set up JDK uses: actions/setup-java@v2 @@ -36,40 +41,45 @@ jobs: - name: Set up Maven run: sudo apt-get install -y maven - - name: Install localstack & awslocal + - name: Start LocalStack + uses: LocalStack/setup-localstack@v0.2.4 + with: + image-tag: 'latest' + use-pro: 'true' + configuration: LS_LOG=trace + install-awslocal: 'true' + env: + LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} + + - name: Install Terraform + uses: hashicorp/setup-terraform@v3 + + - name: Install tflocal run: | - pip install localstack - pip install terraform-local - pip install awscli-local + pip install --upgrade terraform-local - name: Build project run: | cd shipment-picture-lambda-validator mvn clean package shade:shade - - name: Start LocalStack - run: | - docker pull localstack/localstack:latest - # Start LocalStack in the background - LS_LOG=trace localstack start -d - # Wait 30 seconds for the LocalStack container to become ready before timing out - echo "Waiting for LocalStack startup..." - localstack wait -t 15 - echo "Startup complete" - - - name: Run Terraform Config File + - name: Deploy using Terraform run: | cd terraform - bash run-tflocal.sh + tflocal init + tflocal plan + tflocal apply --auto-approve + + - name: Build frontend + run: | + cd shipment-list-frontend + npm install + CI=false npm run build - - name: Check for Bucket + - name: Show LocalStack logs + if: always() run: | - output=$(awslocal s3api list-buckets --query "Buckets[?contains(Name, 'shipment-picture-bucket')].Name" --output text) - if [ -z "$output" ]; then - echo "Created bucket not found." - exit 1 - else echo "Bucket with random name was found: $output" - fi + localstack logs - name: Send a Slack notification if: failure() || github.event_name != 'pull_request' @@ -91,7 +101,7 @@ jobs: - name: Upload the Diagnostic Report if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: diagnose.json.gz - path: ./diagnose.json.gz \ No newline at end of file + path: ./diagnose.json.gz diff --git a/.gitignore b/.gitignore index d4e2fb4..27ff1f9 100644 --- a/.gitignore +++ b/.gitignore @@ -57,11 +57,14 @@ src/main/shipment-list-frontend/yarn-debug.log* src/main/shipment-list-frontend/yarn-error.log* # terraform - -setup/terraform/terraform.tfstate -setup/terraform/.terraform.lock.hcl -setup/terraform/terraform.tfstate.backup +terraform/.terraform/ +terraform/terraform.tfstate +terraform/.terraform.lock.hcl +terraform/terraform.tfstate.backup # lambda module -/shipment-picture-lambda-validator/.idea -/shipment-picture-lambda-validator/target/ +shipment-picture-lambda-validator/.idea +shipment-picture-lambda-validator/target/ + +# frontend +shipment-list-frontend/node_modules diff --git a/shipment-list-frontend/.gitignore b/shipment-list-frontend/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/shipment-list-frontend/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/shipment-picture-lambda-validator/pom.xml b/shipment-picture-lambda-validator/pom.xml index 67ec0a6..7cf6904 100644 --- a/shipment-picture-lambda-validator/pom.xml +++ b/shipment-picture-lambda-validator/pom.xml @@ -57,7 +57,7 @@ org.projectlombok lombok - 1.18.22 + 1.18.30 compile @@ -84,6 +84,20 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + + + org.projectlombok + lombok + 1.18.30 + + + + org.apache.maven.plugins maven-shade-plugin @@ -103,4 +117,4 @@ - \ No newline at end of file + diff --git a/src/main/resources/buckets.properties b/src/main/resources/buckets.properties index 17e66ef..1b2b6aa 100755 --- a/src/main/resources/buckets.properties +++ b/src/main/resources/buckets.properties @@ -1,2 +1,2 @@ -shipment-picture-bucket=shipment-picture-bucket-artistic-alpaca -shipment-picture-bucket-validator=shipment-picture-lambda-validator-bucket-artistic-alpaca +shipment-picture-bucket=shipment-picture-bucket-polite-ghoul +shipment-picture-bucket-validator=shipment-picture-lambda-validator-bucket-polite-ghoul diff --git a/terraform/cleanup.sh b/terraform/cleanup.sh deleted file mode 100644 index 81e33b1..0000000 --- a/terraform/cleanup.sh +++ /dev/null @@ -1,4 +0,0 @@ -rm .terraform.lock.hcl -rm -rf .terraform -rm terraform.tfstate -rm terraform.tfstate.backup \ No newline at end of file diff --git a/terraform/main.tf b/terraform/main.tf index ebecdee..c86d26e 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -1,10 +1,5 @@ terraform { required_providers { - aws = { - source = "hashicorp/aws" - version = "~> 5.59.0" - } - random = { source = "hashicorp/random" version = "~> 3.6.2" diff --git a/terraform/run-tflocal.sh b/terraform/run-tflocal.sh deleted file mode 100644 index 553d0e5..0000000 --- a/terraform/run-tflocal.sh +++ /dev/null @@ -1,3 +0,0 @@ -tflocal init -tflocal plan -tflocal apply --auto-approve \ No newline at end of file