-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2029 from zetkin/main
Release
- Loading branch information
Showing
212 changed files
with
8,056 additions
and
1,542 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
Dockerfile | ||
node_modules | ||
.git | ||
.github | ||
.next | ||
env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Build docker image | ||
|
||
on: | ||
push: | ||
branches: | ||
- "release" | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{ github.repository }} | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
attestations: write | ||
id-token: write | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
# Buildx is necessary for GitHub Actions caching to work | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log in to the Container registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
# The image will be tagged YYMMDD and YYMMDD-abcdef, | ||
# where abcdef is the shortform hash of the last commit | ||
tags: | | ||
type=sha,prefix={{date 'YYMMDD'}}- | ||
type=raw,value={{date 'YYMMDD'}} | ||
type=raw,value=latest | ||
- name: Build and push Docker image | ||
id: push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./env/frontend/Dockerfile | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- name: Generate artifact attestation | ||
uses: actions/attest-build-provenance@v1 | ||
with: | ||
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}} | ||
subject-digest: ${{ steps.push.outputs.digest }} | ||
push-to-registry: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ | |
|
||
if [[ "$NODE_ENV" == "production" ]]; | ||
then | ||
yarn build | ||
yarn start | ||
else | ||
yarn dev | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
import shouldLoad from './shouldLoad'; | ||
import { remoteItem, remoteList } from 'utils/storeUtils'; | ||
|
||
describe('shouldLoad()', () => { | ||
const dummyItemData = { | ||
id: 1, | ||
title: 'Dummy', | ||
}; | ||
|
||
describe('with lists', () => { | ||
it('returns true when list is undefined', () => { | ||
const result = shouldLoad(undefined); | ||
expect(result).toBeTruthy(); | ||
}); | ||
|
||
it('returns true when list has not loaded', () => { | ||
const list = remoteList([dummyItemData]); | ||
list.loaded = null; | ||
|
||
const result = shouldLoad(list); | ||
expect(result).toBeTruthy(); | ||
}); | ||
|
||
it('returns true when list has loaded but is stale', () => { | ||
const list = remoteList([dummyItemData]); | ||
list.loaded = new Date().toISOString(); | ||
list.isStale = true; | ||
|
||
const result = shouldLoad(list); | ||
expect(result).toBeTruthy(); | ||
}); | ||
|
||
it('returns true when list has loaded but too long ago', () => { | ||
const loaded = new Date(); | ||
loaded.setMinutes(loaded.getMinutes() - 6); | ||
|
||
const list = remoteList([dummyItemData]); | ||
list.loaded = loaded.toISOString(); | ||
|
||
const result = shouldLoad(list); | ||
expect(result).toBeTruthy(); | ||
}); | ||
|
||
it('returns false when list has loaded recently', () => { | ||
const list = remoteList([dummyItemData]); | ||
list.loaded = new Date().toISOString(); | ||
|
||
const result = shouldLoad(list); | ||
expect(result).toBeFalsy(); | ||
}); | ||
|
||
it('returns false when list is already loading', () => { | ||
const list = remoteList([dummyItemData]); | ||
list.isLoading = true; | ||
|
||
const result = shouldLoad(list); | ||
expect(result).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe('with items', () => { | ||
it('returns true when item is undefined', () => { | ||
const result = shouldLoad(undefined); | ||
expect(result).toBeTruthy(); | ||
}); | ||
|
||
it('returns true when item has not loaded', () => { | ||
const item = remoteItem(dummyItemData.id); | ||
item.loaded = null; | ||
|
||
const result = shouldLoad(item); | ||
expect(result).toBeTruthy(); | ||
}); | ||
|
||
it('returns true when item has loaded but is stale', () => { | ||
const item = remoteItem(dummyItemData.id); | ||
item.loaded = new Date().toISOString(); | ||
item.isStale = true; | ||
|
||
const result = shouldLoad(item); | ||
expect(result).toBeTruthy(); | ||
}); | ||
|
||
it('returns true when item has loaded but too long ago', () => { | ||
const loaded = new Date(); | ||
loaded.setMinutes(loaded.getMinutes() - 6); | ||
|
||
const item = remoteItem(dummyItemData.id); | ||
item.loaded = loaded.toISOString(); | ||
item.isStale = true; | ||
|
||
const result = shouldLoad(item); | ||
expect(result).toBeTruthy(); | ||
}); | ||
|
||
it('returns false when item has loaded recently', () => { | ||
const item = remoteItem(dummyItemData.id); | ||
item.loaded = new Date().toISOString(); | ||
|
||
const result = shouldLoad(item); | ||
expect(result).toBeFalsy(); | ||
}); | ||
|
||
it('returns false when item is already loading', () => { | ||
const item = remoteItem(dummyItemData.id); | ||
item.isLoading = true; | ||
|
||
const result = shouldLoad(item); | ||
expect(result).toBeFalsy(); | ||
}); | ||
|
||
it('returns false when item is deleted', () => { | ||
const item = remoteItem(dummyItemData.id); | ||
item.deleted = true; | ||
|
||
const result = shouldLoad(item); | ||
expect(result).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe('with map of lists', () => { | ||
it('returns true when any needs loading', () => { | ||
const map = { | ||
'1': remoteList([dummyItemData]), | ||
'2': remoteList([dummyItemData]), | ||
}; | ||
|
||
// List for 1 needs loading | ||
map[1].isStale = true; | ||
|
||
const result = shouldLoad(map, [1, 2]); | ||
expect(result).toBeTruthy(); | ||
}); | ||
|
||
it('returns false when none need loading', () => { | ||
const map = { | ||
'1': remoteList([dummyItemData]), | ||
'2': remoteList([dummyItemData]), | ||
}; | ||
|
||
// Both lists have loaded | ||
map[1].loaded = new Date().toISOString(); | ||
map[2].loaded = new Date().toISOString(); | ||
|
||
const result = shouldLoad(map, [1, 2]); | ||
expect(result).toBeFalsy(); | ||
}); | ||
|
||
it('returns true when ID is not in map', () => { | ||
const result = shouldLoad({}, [1, 2]); | ||
expect(result).toBeTruthy(); | ||
}); | ||
}); | ||
|
||
describe('with map of items', () => { | ||
it('returns true when any needs loading', () => { | ||
const map = { | ||
'1': remoteItem(dummyItemData.id), | ||
'2': remoteItem(dummyItemData.id), | ||
}; | ||
|
||
// List for 1 needs loading | ||
map[1].isStale = true; | ||
|
||
const result = shouldLoad(map, [1, 2]); | ||
expect(result).toBeTruthy(); | ||
}); | ||
|
||
it('returns false when none need loading', () => { | ||
const map = { | ||
'1': remoteItem(dummyItemData.id), | ||
'2': remoteItem(dummyItemData.id), | ||
}; | ||
|
||
// Both lists have loaded | ||
map[1].loaded = new Date().toISOString(); | ||
map[2].loaded = new Date().toISOString(); | ||
|
||
const result = shouldLoad(map, [1, 2]); | ||
expect(result).toBeFalsy(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.