Skip to content

Commit

Permalink
Merge branch 'staging' into fix/continuous-delivery
Browse files Browse the repository at this point in the history
  • Loading branch information
lodewiges authored Nov 12, 2024
2 parents 1087289 + 26f13a0 commit dd37aa9
Show file tree
Hide file tree
Showing 164 changed files with 3,927 additions and 896 deletions.
16 changes: 5 additions & 11 deletions .github/workflows/cleanup-registry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,14 @@ on:
- cron: '0 0 * * 1' # https://crontab.guru/#0_0_*_*_1
workflow_dispatch:

env:
IMAGE_NAMES: amber-ui

jobs:
cleanup:
name: Cleanup
runs-on: ubuntu-latest
steps:
- name: Delete old versions
uses: snok/container-retention-policy@f617f1ca161a52bce48417eedd76924e71d0b4d9 # v2.1.0
- name: Delete untagged images
uses: actions/delete-package-versions@0d39a63126868f5eefaa47169615edd3c0f61e20 # v4.1.1
with:
image-names: ${{ env.IMAGE_NAMES }}
cut-off: 2 days ago UTC
account-type: org
org-name: ${{ github.repository_owner }}
skip-tags: latest,staging
token: ${{ secrets.GH_PAT }}
package-name: ${{ github.event.repository.name }}
package-type: container
delete-only-untagged-versions: true
10 changes: 6 additions & 4 deletions .github/workflows/continuous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
stage: ${{ steps.get_metadata.outputs.stage }}
steps:
- name: Checkout code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Get metadata
id: get_metadata
Expand Down Expand Up @@ -85,8 +85,8 @@ jobs:
fi
- name: Checkout code
if: fromJSON(needs.metadata.outputs.has_diff) || github.event.inputs.ignore_metadata_diff
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
if: fromJSON(needs.metadata.outputs.has_diff)
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Run merge
if: fromJSON(needs.metadata.outputs.has_diff) || github.event.inputs.ignore_metadata_diff
Expand All @@ -111,6 +111,8 @@ jobs:
uses: csvalpha/amber-ui/.github/workflows/continuous-integration.yml@staging
with:
sha: ${{ needs.merge.outputs.sha }}
secrets:
codecov_token: ${{ secrets.CODECOV_TOKEN }}

publish_image:
name: Publish Image
Expand Down Expand Up @@ -141,7 +143,7 @@ jobs:
fi
- name: Checkout code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ needs.merge.outputs.sha }}

Expand Down
31 changes: 28 additions & 3 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ on:
description: The commit SHA to run the workflow on
required: false
type: string
secrets:
codecov_token:
description: Codecov token
required: true

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ inputs.sha }}

Expand All @@ -35,7 +39,7 @@ jobs:
needs: build
steps:
- name: Checkout code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ inputs.sha }}

Expand Down Expand Up @@ -70,11 +74,32 @@ jobs:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ inputs.sha }}

- name: Load test image
uses: guidojw/actions/load-docker-image@abb0ee8d1336edf73383f2e5a09abd3a22f25b13 # v1.3.3
with:
name: app

- name: Test
run: |
docker run -e CI=true -t app yarn test:ember
mkdir coverage
docker run -e CI=true -e COVERAGE=true -v "$(pwd)"'/coverage:/opt/app/coverage' app yarn test:ember
- name: Upload coverage report to Codecov
if: ${{ !cancelled() }}
uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab # v4.1.0
with:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Upload coverage report artifact
if: ${{ !cancelled() }}
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: coverage
path: coverage/
if-no-files-found: error
6 changes: 3 additions & 3 deletions .github/workflows/publish-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
needs: metadata
steps:
- name: Checkout code
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ inputs.sha }}
fetch-depth: 0
Expand All @@ -64,15 +64,15 @@ jobs:
uses: docker/setup-buildx-action@4b4e9c3e2d4531116a6f8ba8e71fc6e2cb6e6c8c # v2.5.0

- name: Login to GitHub Container Registry
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # tag=v2.1.0
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ${{ vars.DOCKER_REGISTRY_URL }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push image
id: build_push_image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671 # v4.0.0
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6.9.0
with:
push: true
context: .
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

[![Continuous Integration](https://github.com/csvalpha/amber-ui/actions/workflows/continuous-integration.yml/badge.svg)](https://github.com/csvalpha/amber-ui/actions/workflows/continuous-integration.yml)
[![Continuous Delivery](https://github.com/csvalpha/amber-ui/actions/workflows/continuous-delivery.yml/badge.svg)](https://github.com/csvalpha/amber-ui/actions/workflows/continuous-delivery.yml)
[![codecov](https://codecov.io/gh/csvalpha/amber-ui/graph/badge.svg?token=GMTXV28YQF)](https://codecov.io/gh/csvalpha/amber-ui)

## Prerequisites

Expand Down
36 changes: 36 additions & 0 deletions app/abilities/photo-tag.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Ability } from 'ember-can';
import { isNone } from '@ember/utils';

export default class PhotoTag extends Ability {
get canShow() {
return this.session.hasPermission('photo-tag.read');
}

get canCreate() {
return this.session.hasPermission('photo-tag.create');
}

get canDestroy() {
return (
this.session.hasPermission('photo-tag.destroy') ||
this.isTagOwner(this.model) ||
this.isTagged(this.model)
);
}

isTagOwner(photoTag) {
const { currentUser } = this.session;
return (
!isNone(currentUser) &&
photoTag.get('author.id') === currentUser.get('id')
);
}

isTagged(photoTag) {
const { currentUser } = this.session;
return (
!isNone(currentUser) &&
photoTag.get('taggedUser.id') === currentUser.get('id')
);
}
}
4 changes: 4 additions & 0 deletions app/abilities/photo.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ export default class Photo extends Ability {
this.model.photoAlbum.get('publiclyVisible')
);
}

get canShowPhotoTags() {
return this.session.hasPermission('photo-tag.read');
}
}
11 changes: 0 additions & 11 deletions app/abilities/quickpost-message.js

This file was deleted.

31 changes: 31 additions & 0 deletions app/abilities/room-advert.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { isNone } from '@ember/utils';
import { Ability } from 'ember-can';

export default class RoomAdvert extends Ability {
get canCreate() {
return this.session.hasPermission('room-advert.create');
}

get canShow() {
return this.session.hasPermission('room-advert.read');
}

get canDestroy() {
return (
this.session.hasPermission('room-advert.destroy') ||
this.isRoomAdvertOwner(this.model)
);
}

get canEdit() {
return (
this.session.hasPermission('room-advert.update') ||
this.isRoomAdvertOwner(this.model)
);
}

isRoomAdvertOwner(roomAdvert) {
const { currentUser } = this.session;
return !isNone(currentUser) && roomAdvert.isOwner(currentUser);
}
}
1 change: 1 addition & 0 deletions app/adapters/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export default class ApplicationAdapter extends JSONAPIAdapter {
let headers = {};
if (this.session.isAuthenticated) {
headers.Authorization = `Bearer ${this.session.data.authenticated.access_token}`;
document.documentElement.classList.add('authenticated');
}

return headers;
Expand Down
Loading

0 comments on commit dd37aa9

Please sign in to comment.