Skip to content

Commit

Permalink
Attempt to cache postgres docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
karthick-vinod committed Apr 13, 2024
1 parent 571e1ee commit a78792a
Show file tree
Hide file tree
Showing 10 changed files with 101 additions and 266 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,27 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- id: image-cache
uses: actions/cache@v4
with:
path: image-cache
key: image-cache-${{ runner.os }}
- if: steps.image-cache.outputs.cache-hit != 'true'
run: |
echo "Cache miss!"
docker pull postgres:14.1-alpine
docker save -o ~/image-cache/postgres.tar postgres:14.1-alpine
- if: steps.image-cache.outputs.cache-hit == 'true'
run: |
echo "Cache hit!"
docker load -i ~/image-cache/postgres.tar
- name: Run Postgres
run: |
docker-compose -f docker-compose.yml up -d pg
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
env_file:
- ./docker/iam-web/dev.env
pg:
image: postgres:14.1
image: postgres:14.1-alpine
ports:
- "4921:5432"
environment:
Expand Down
16 changes: 8 additions & 8 deletions src/test/kotlin/com/hypto/iam/server/apis/ActionApiTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package com.hypto.iam.server.apis

import com.hypto.iam.server.Constants
import com.hypto.iam.server.helpers.BaseSingleAppTest
import com.hypto.iam.server.helpers.DataSetupHelper.deleteOrganization
import com.hypto.iam.server.helpers.DataSetupHelperV3.createAction
import com.hypto.iam.server.helpers.DataSetupHelperV3.createOrganization
import com.hypto.iam.server.helpers.DataSetupHelperV3.createResource
import com.hypto.iam.server.helpers.DataSetupHelperV3.deleteOrganization
import com.hypto.iam.server.models.Action
import com.hypto.iam.server.models.ActionPaginatedResponse
import com.hypto.iam.server.models.BaseSuccessResponse
Expand Down Expand Up @@ -55,7 +55,7 @@ class ActionApiTest : BaseSingleAppTest() {
assertEquals(organization.id, responseBody.organizationId)
assertEquals("", responseBody.description)

deleteOrganization(organization.id)
testApp.deleteOrganization(organization.id)
}
}

Expand Down Expand Up @@ -85,7 +85,7 @@ class ActionApiTest : BaseSingleAppTest() {
assertEquals(organization.id, responseBody.organizationId)
assertEquals(resource.name, responseBody.resourceName)

deleteOrganization(organization.id)
testApp.deleteOrganization(organization.id)
}
}

Expand Down Expand Up @@ -114,8 +114,8 @@ class ActionApiTest : BaseSingleAppTest() {
response.contentType(),
)

deleteOrganization(organization1.id)
deleteOrganization(organization2.id)
testApp.deleteOrganization(organization1.id)
testApp.deleteOrganization(organization2.id)
}
}

Expand Down Expand Up @@ -147,7 +147,7 @@ class ActionApiTest : BaseSingleAppTest() {
}
assertEquals(HttpStatusCode.NotFound, response.status)

deleteOrganization(organization.id)
testApp.deleteOrganization(organization.id)
}
}

Expand Down Expand Up @@ -177,7 +177,7 @@ class ActionApiTest : BaseSingleAppTest() {
assert(responseBody.data!!.contains(action1))
assert(responseBody.data!!.contains(action2))

deleteOrganization(organization.id)
testApp.deleteOrganization(organization.id)
}
}

Expand Down Expand Up @@ -209,7 +209,7 @@ class ActionApiTest : BaseSingleAppTest() {
assertEquals(resource.name, responseBody.resourceName)
assertEquals(newDescription, responseBody.description)

deleteOrganization(organization.id)
testApp.deleteOrganization(organization.id)
}
}
}
24 changes: 12 additions & 12 deletions src/test/kotlin/com/hypto/iam/server/apis/CredentialApiKtTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package com.hypto.iam.server.apis

import com.hypto.iam.server.Constants
import com.hypto.iam.server.helpers.BaseSingleAppTest
import com.hypto.iam.server.helpers.DataSetupHelper.deleteOrganization
import com.hypto.iam.server.helpers.DataSetupHelperV3.createCredential
import com.hypto.iam.server.helpers.DataSetupHelperV3.createOrganization
import com.hypto.iam.server.helpers.DataSetupHelperV3.deleteOrganization
import com.hypto.iam.server.models.CreateCredentialRequest
import com.hypto.iam.server.models.Credential
import com.hypto.iam.server.models.ListCredentialResponse
Expand Down Expand Up @@ -66,7 +66,7 @@ internal class CredentialApiKtTest : BaseSingleAppTest() {
Assertions.assertEquals(Credential.Status.active, responseBody.status)
Assertions.assertNotNull(responseBody.secret)

deleteOrganization(createdOrganization.id)
testApp.deleteOrganization(createdOrganization.id)
}
}

Expand Down Expand Up @@ -105,7 +105,7 @@ internal class CredentialApiKtTest : BaseSingleAppTest() {
Assertions.assertEquals(Credential.Status.active, responseBody.status)
Assertions.assertNotNull(responseBody.secret)

deleteOrganization(createdOrganization.id)
testApp.deleteOrganization(createdOrganization.id)
}
}

Expand Down Expand Up @@ -134,7 +134,7 @@ internal class CredentialApiKtTest : BaseSingleAppTest() {
Json,
response.contentType(),
)
deleteOrganization(createdOrganization.id)
testApp.deleteOrganization(createdOrganization.id)
}
}

Expand Down Expand Up @@ -171,7 +171,7 @@ internal class CredentialApiKtTest : BaseSingleAppTest() {
Json,
response.contentType(),
)
deleteOrganization(createdOrganization.id)
testApp.deleteOrganization(createdOrganization.id)
}
}
}
Expand Down Expand Up @@ -233,7 +233,7 @@ internal class CredentialApiKtTest : BaseSingleAppTest() {
}
Assertions.assertEquals(HttpStatusCode.Unauthorized, response.status)

deleteOrganization(createdOrganization.id)
testApp.deleteOrganization(createdOrganization.id)
}
}

Expand All @@ -258,7 +258,7 @@ internal class CredentialApiKtTest : BaseSingleAppTest() {
Assertions.assertEquals(HttpStatusCode.NotFound, response.status)
Assertions.assertEquals(Json, response.contentType())

deleteOrganization(createdOrganization.id)
testApp.deleteOrganization(createdOrganization.id)
}
}

Expand All @@ -285,8 +285,8 @@ internal class CredentialApiKtTest : BaseSingleAppTest() {
}
Assertions.assertEquals(HttpStatusCode.Forbidden, response.status)
Assertions.assertEquals(Json, response.contentType())
deleteOrganization(organization1.id)
deleteOrganization(organizationResponse2.organization.id)
testApp.deleteOrganization(organization1.id)
testApp.deleteOrganization(organizationResponse2.organization.id)
}
}
}
Expand Down Expand Up @@ -319,7 +319,7 @@ internal class CredentialApiKtTest : BaseSingleAppTest() {
Assertions.assertNull(responseBody.secret)
Assertions.assertEquals(Credential.Status.active, responseBody.status)

deleteOrganization(createdOrganization.id)
testApp.deleteOrganization(createdOrganization.id)
}
}

Expand All @@ -342,7 +342,7 @@ internal class CredentialApiKtTest : BaseSingleAppTest() {
Assertions.assertEquals(HttpStatusCode.NotFound, response.status)
Assertions.assertEquals(Json, response.contentType())

deleteOrganization(createdOrganization.id)
testApp.deleteOrganization(createdOrganization.id)
}
}

Expand All @@ -363,7 +363,7 @@ internal class CredentialApiKtTest : BaseSingleAppTest() {
}
Assertions.assertEquals(HttpStatusCode.BadRequest, response.status)
Assertions.assertEquals(Json, response.contentType())
deleteOrganization(createdOrganization.id)
testApp.deleteOrganization(createdOrganization.id)
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/test/kotlin/com/hypto/iam/server/apis/KeyApiTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.hypto.iam.server.apis

import com.hypto.iam.server.helpers.BaseSingleAppTest
import com.hypto.iam.server.helpers.DataSetupHelperV3.createOrganization
import com.hypto.iam.server.helpers.DataSetupHelperV3.deleteOrganization
import com.hypto.iam.server.models.KeyResponse
import com.hypto.iam.server.models.TokenResponse
import com.hypto.iam.server.service.TokenServiceImpl
Expand Down Expand Up @@ -70,6 +71,8 @@ class KeyApiTest : BaseSingleAppTest() {
assertDoesNotThrow {
Jwts.parserBuilder().setSigningKey(publicKey).build().parseClaimsJws(token)
}

testApp.deleteOrganization(organizationResponse.organization.id)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import com.hypto.iam.server.db.repositories.PasscodeRepo
import com.hypto.iam.server.db.tables.pojos.Organizations
import com.hypto.iam.server.db.tables.records.PasscodesRecord
import com.hypto.iam.server.helpers.BaseSingleAppTest
import com.hypto.iam.server.helpers.DataSetupHelper.deleteOrganization
import com.hypto.iam.server.helpers.DataSetupHelperV3.deleteOrganization
import com.hypto.iam.server.models.CreateOrganizationRequest
import com.hypto.iam.server.models.CreateOrganizationResponse
import com.hypto.iam.server.models.Organization
Expand Down Expand Up @@ -145,7 +145,7 @@ internal class OrganizationApiKtTest : BaseSingleAppTest() {
Assertions.assertEquals(1, policies.data?.size)
Assertions.assertEquals("admin", policies.data!![0].name)

deleteOrganization(orgId)
testApp.deleteOrganization(orgId)
}
}

Expand Down Expand Up @@ -244,7 +244,7 @@ internal class OrganizationApiKtTest : BaseSingleAppTest() {
assertEquals(requestBody.name, responseBody.organization.name)
assertEquals(10, responseBody.organization.id.length)

deleteOrganization(orgId)
testApp.deleteOrganization(orgId)
}
}

Expand Down Expand Up @@ -310,7 +310,7 @@ internal class OrganizationApiKtTest : BaseSingleAppTest() {
assertEquals(orgName, responseBody.organization.name)
assertEquals(10, responseBody.organization.id.length)

deleteOrganization(orgId)
testApp.deleteOrganization(orgId)
}
}

Expand Down Expand Up @@ -358,7 +358,7 @@ internal class OrganizationApiKtTest : BaseSingleAppTest() {

// Cleanup
val orgId = responseBody.organization.id
deleteOrganization(orgId)
testApp.deleteOrganization(orgId)
}
}

Expand Down Expand Up @@ -478,7 +478,7 @@ internal class OrganizationApiKtTest : BaseSingleAppTest() {
assertFalse(response.headers.contains(HttpHeaders.ContentType))
assertNull(response.headers[Constants.X_ORGANIZATION_HEADER])

deleteOrganization(createdOrganization.organization.id)
testApp.deleteOrganization(createdOrganization.organization.id)
}
}

Expand Down Expand Up @@ -525,7 +525,7 @@ internal class OrganizationApiKtTest : BaseSingleAppTest() {
val fetchedOrganization = gson.fromJson(response.bodyAsText(), Organization::class.java)
assertEquals(createdOrganization.organization, fetchedOrganization)

deleteOrganization(createdOrganization.organization.id)
testApp.deleteOrganization(createdOrganization.organization.id)
}
}

Expand Down Expand Up @@ -572,7 +572,7 @@ internal class OrganizationApiKtTest : BaseSingleAppTest() {
}
// These assertions
assertEquals(HttpStatusCode.Forbidden, response.status)
deleteOrganization(createdOrganization.organization.id)
testApp.deleteOrganization(createdOrganization.organization.id)
}
}

Expand Down
11 changes: 6 additions & 5 deletions src/test/kotlin/com/hypto/iam/server/apis/PolicyApiTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.hypto.iam.server.helpers.DataSetupHelperV3.createAndAttachPolicy
import com.hypto.iam.server.helpers.DataSetupHelperV3.createOrganization
import com.hypto.iam.server.helpers.DataSetupHelperV3.createResourceActionHrn
import com.hypto.iam.server.helpers.DataSetupHelperV3.createUser
import com.hypto.iam.server.helpers.DataSetupHelperV3.deleteOrganization
import com.hypto.iam.server.models.CreatePolicyFromTemplateRequest
import com.hypto.iam.server.models.CreatePolicyRequest
import com.hypto.iam.server.models.CreateUserRequest
Expand Down Expand Up @@ -100,7 +101,7 @@ internal class PolicyApiTest : BaseSingleAppTest() {
Assertions.assertEquals(1, responseBody.version)
Assertions.assertEquals(policyStatements, responseBody.statements)

deleteOrganization(createdOrganization.id)
testApp.deleteOrganization(createdOrganization.id)
}
}

Expand Down Expand Up @@ -252,7 +253,7 @@ internal class PolicyApiTest : BaseSingleAppTest() {
response.contentType(),
)

deleteOrganization(createdOrganization.id)
testApp.deleteOrganization(createdOrganization.id)
}
}

Expand Down Expand Up @@ -334,7 +335,7 @@ internal class PolicyApiTest : BaseSingleAppTest() {

// cleanup
policyTempRecord.delete()
deleteOrganization(createdOrganization.id)
testApp.deleteOrganization(createdOrganization.id)
}
}
}
Expand Down Expand Up @@ -1037,7 +1038,7 @@ internal class PolicyApiTest : BaseSingleAppTest() {
header(HttpHeaders.ContentType, ContentType.Application.Json.toString())
}
Assertions.assertEquals(HttpStatusCode.Forbidden, response.status)
deleteOrganization(organization.id)
testApp.deleteOrganization(organization.id)
}
}

Expand Down Expand Up @@ -1108,7 +1109,7 @@ internal class PolicyApiTest : BaseSingleAppTest() {

val responseBody = gson.fromJson(response.bodyAsText(), PolicyPaginatedResponse::class.java)
Assertions.assertEquals(0, responseBody.data!!.size)
deleteOrganization(organization.id)
testApp.deleteOrganization(organization.id)
}
}
}
Expand Down
Loading

0 comments on commit a78792a

Please sign in to comment.