Skip to content

Commit

Permalink
Merge branch 'main' into fix/skilavottord-error-shown-after-cancel-de…
Browse files Browse the repository at this point in the history
…registration
  • Loading branch information
veronikasif authored Dec 13, 2024
2 parents bea4271 + 3719969 commit fe81fb4
Show file tree
Hide file tree
Showing 3,264 changed files with 76,993 additions and 55,713 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
43 changes: 36 additions & 7 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
node_modules/
dist/
scripts/ci/
# vi: ft=gitignore

# Known ignores
/.github/
/.git/
/scripts/ci/
/.env.*
/.envrc*
/.nx/

# Cache and packages
**/node_modules/
# Ignoring _all_ cache folders dosen't work, because we have libraries named `cache`
# **/cache/
/.yarn/cache/
/.yarn/install-state*
# Ignores e.g. `cache/` and `cache_outptut/`
/cache*
cache/
.git/
log/
*.log
/.cache*/

# Logs and temporaries
**/log/
**/*.log
**/tmp/
**/temp/

# Outputs
**/dist/
**/out/

# Docker-stuff
**/Dockerfile
**/Dockerfile.*
**/Containerfile
**/Containerfile.*
**/*-compose.yaml
**/*-compose.yml
775 changes: 394 additions & 381 deletions .github/CODEOWNERS

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ jobs:
runs-on: ec2-runners
container:
image: public.ecr.aws/m3u4c4h9/island-is/actions-runner-public:latest
timeout-minutes: 35
timeout-minutes: 45
env:
AFFECTED_PROJECTS: ${{ matrix.projects }}
MAX_JOBS: 1
Expand Down Expand Up @@ -220,7 +220,7 @@ jobs:
runs-on: ec2-runners
container:
image: public.ecr.aws/m3u4c4h9/island-is/actions-runner-public:latest
timeout-minutes: 35
timeout-minutes: 45
env:
AFFECTED_PROJECT: ${{ matrix.projects }}
CYPRESS_PROJECT_ID: 4q7jz8
Expand Down Expand Up @@ -288,8 +288,7 @@ jobs:
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
fail_on_error: true
level: info
fail-level: info
exclude: >-
*/node_modules/*
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,14 @@ jobs:
uses: docker/setup-qemu-action@v3
with:
image: '${{ env.DOCKER_BASE_IMAGE_REGISTRY }}/eks-distro-build-tooling/binfmt-misc:qemu-v6.1.0'
- name: Check if cached buildx image exists
id: cache-check
run: |
if ! docker pull ${{vars.AWS_ECR_REPO_BASE}}/moby/buildkit:buildx-stable-1 ; then
docker pull docker.io/moby/buildkit:buildx-stable-1
docker tag docker.io/moby/buildkit:buildx-stable-1 ${{vars.AWS_ECR_REPO_BASE}}/moby/buildkit:buildx-stable-1
docker push ${{vars.AWS_ECR_REPO_BASE}}/moby/buildkit:buildx-stable-1
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
Expand Down Expand Up @@ -555,6 +563,14 @@ jobs:
uses: docker/setup-qemu-action@v3
with:
image: '${{ env.DOCKER_BASE_IMAGE_REGISTRY }}/eks-distro-build-tooling/binfmt-misc:qemu-v6.1.0'
- name: Check if cached buildx image exists
id: cache-check
run: |
if ! docker pull ${{vars.AWS_ECR_REPO_BASE}}/moby/buildkit:buildx-stable-1 ; then
docker pull docker.io/moby/buildkit:buildx-stable-1
docker tag docker.io/moby/buildkit:buildx-stable-1 ${{vars.AWS_ECR_REPO_BASE}}/moby/buildkit:buildx-stable-1
docker push ${{vars.AWS_ECR_REPO_BASE}}/moby/buildkit:buildx-stable-1
fi
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
Expand Down
105 changes: 105 additions & 0 deletions .github/workflows/revert-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Checksuit

on:
workflow_run:
workflows:
- Monorepo pipeline - build and deploy
types:
- completed
branches:
- main
pull_request:
types:
- opened
- synchronize
- labeled

permissions:
contents: write
pull-requests: write

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
detect-failure:
name: Determine Failure
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
runs-on: ec2-runners
container:
image: public.ecr.aws/m3u4c4h9/island-is/actions-runner-public:latest
outputs:
PR_NUMBER: ${{ steps.fetch-pr.outputs.PR_NUMBER }}
steps:
- uses: actions/checkout@v4

- name: Debug
run: |
echo "Conclusion: ${{ github.event.workflow_run.conclusion }}"
- name: Fetch PR
id: fetch-pr
run: |
COMMIT_SHA="${{ github.event.workflow_run.head_commit.id }}"
if ! PR_NUMBER=$(bash ./scripts/ci/get-pr.sh "$COMMIT_SHA"); then
echo "Error: Failed to get PR number for commit $COMMIT_SHA"
exit 1
fi
if [ -n "$PR_NUMBER" ]; then
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
else
echo "No merged PR found for commit $COMMIT_SHA."
fi
- name: Add Revert Label
id: add-revert-label
if: ${{ steps.fetch-pr.outputs.PR_NUMBER && github.event.workflow_run.conclusion == 'failure' }}
run: |
PR_NUMBER="${{ steps.fetch-pr.outputs.PR_NUMBER }}"
if [ -z "$PR_NUMBER" ]; then
echo "Error: PR number is empty"
exit 1
fi
echo "Adding revert label to PR: $PR_NUMBER"
if ! gh pr edit "$PR_NUMBER" --add-label "revert"; then
echo "Error: Failed to add revert label"
exit 1
fi
create-revert-pr:
name: Automated PR revert
needs: detect-failure
if: ${{ needs.detect-failure.outputs.PR_NUMBER && github.event.workflow_run.conclusion == 'failure' }}
runs-on: ec2-runners
container:
image: public.ecr.aws/m3u4c4h9/island-is/actions-runner-public:latest
steps:
- name: Debug
run: |
PR_NUMBER=${{ needs.detect-failure.outputs.PR_NUMBER }}
echo "Reverting PR: $PR_NUMBER"
- name: Execute PR revert
if: ${{ vars.ENABLE_PR_REVERT == 'true' }}
run: |
REVERT_PR=$(bash ./scripts/ci/revert-pr.sh "$PR_NUMBER")
gh pr edit $REVERT_PR --add-label "automerge,high priority"
manual-revert-pr:
name: Manual PR revert
runs-on: ec2-runners
container:
image: public.ecr.aws/m3u4c4h9/island-is/actions-runner-public:latest
if: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'revert') && (github.event.pull_request.merged == true || github.event.pull_request.draft == true) && github.actor != 'github-actions' }}
steps:
- name: Debug
run: |
echo "actor: ${{ github.actor }}"
echo "Reverting PR: ${{ github.event.pull_request.number }}"
- name: Execute PR revert
if: ${{ vars.ENABLE_PR_REVERT == 'true' }}
run: |
REVERT_PR=$(bash ./scripts/ci/revert-pr.sh "${{ github.event.pull_request.number }}")
gh pr edit $REVERT_PR --add-label "automerge,high priority"
68 changes: 67 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,70 @@ apps/**/index.html
# E2E outputs
test-results/
playwright-report/
tmp-sessions/
tmp-sessions/

# React Native

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.dSYM.zip
*.xcuserstate
**/.xcode.env.local
ios/*.cer
ios/*.certSigningRequest
ios/*.mobileprovision
ios/*.p12

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml
*.hprof
.cxx/
*.keystore
!debug.keystore
google-services.json
service-account.json

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

**/fastlane/report.xml
**/fastlane/Preview.html
**/fastlane/screenshots
**/fastlane/test_output

# Bundle artifact
*.jsbundle

# Ruby / CocoaPods
**/Pods/
**/vendor/bundle/

# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*

# testing
/coverage
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Run on whenever you check out a branch:

```bash
yarn install
yarn infra install
(cd infra/ && yarn install)
yarn codegen
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { UserService } from '../user/user.service'
import type { User as AuthUser } from '@island.is/auth-nest-tools'
import { ExplicitFlight } from './dto/ExplicitFlight.dto'
import { CreateSuperExplicitDiscountCodeParams } from './dto'
import type { Logger } from '@island.is/logging'
import { LOGGER_PROVIDER } from '@island.is/logging'

interface CachedDiscount {
user: User
Expand Down Expand Up @@ -47,6 +49,8 @@ export class DiscountService {

@InjectModel(ExplicitCode)
private explicitModel: typeof ExplicitCode,
@Inject(LOGGER_PROVIDER)
private readonly logger: Logger,

private readonly userService: UserService,
) {}
Expand Down Expand Up @@ -197,13 +201,19 @@ export class DiscountService {
unConnectedFlights: Flight[] | ExplicitFlight[],
isExplicit: boolean,
flightLegs = 1,
isManual?: boolean,
): Promise<Array<Discount> | null> {
const user = await this.userService.getUserInfoByNationalId(
nationalId,
auth,
isExplicit,
isManual,
)

if (!user) {
this.logger.warn('User by national id not found for explicit discount.', {
category: 'ads-backend',
})
return null
}
// overwrite credit since validation may return 0 depending on what the problem is
Expand All @@ -212,10 +222,19 @@ export class DiscountService {
user.fund.credit = 2 //making sure we can get flight from and to
user.fund.total = 2
} else {
this.logger.warn(
`User fund used requirements not met: ${user.fund.used}.`,
{
category: 'ads-backend',
},
)
return null
}
}
if (user.fund.credit === 0 && user.fund.total !== undefined) {
this.logger.warn(`User fund no credit, has total: ${user.fund.total}.`, {
category: 'ads-backend',
})
return null
}

Expand Down Expand Up @@ -477,6 +496,7 @@ export class DiscountService {
],
}

const isManual = true
const discount = await this.createExplicitDiscountCode(
auth,
body.nationalId,
Expand All @@ -487,6 +507,7 @@ export class DiscountService {
body.needsConnectionFlight ? [flight] : [],
isExplicit,
1,
isManual,
)
if (!discount) {
throw new Error(`Could not create explicit discount`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ describe('DiscountService', () => {
{
provide: LOGGER_PROVIDER,
useClass: jest.fn(() => ({
error: () => ({}),
error: jest.fn(),
info: jest.fn(),
warn: jest.fn(),
})),
},
{
Expand Down
Loading

0 comments on commit fe81fb4

Please sign in to comment.