Skip to content

Commit

Permalink
add ci
Browse files Browse the repository at this point in the history
  • Loading branch information
lesomnus committed Jul 20, 2024
1 parent e73e0bf commit 69524cb
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 7 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Built and Test
on:
pull_request:
push:
branches:
- main

permissions:
contents: read

jobs:
check:
runs-on: ubuntu-latest

services:
registry:
image: ghcr.io/project-zot/zot-minimal:v2.1.0
ports:
- 5000:5000

strategy:
matrix:
node: [20, 22]
steps:
- name: Wait registry
run: >
for ((i=1; i<=30; i++)); do
status_code=$(curl -o /dev/null -s -w "%{http_code}\n" "http://registry:5000/v2/")
if [ "$status_code" -eq 200 ]; then
exit 0
fi
sleep 1
done
exit 1
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: npm

- run: npm clean-install
- run: npx biome ci .
- run: npm test
- run: npm run build
6 changes: 3 additions & 3 deletions src/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ describe.concurrent('api v2', async () => {
...init,
manifest: {
schemaVersion: 2,
mediaType: oci.image.ManifestV1 as string,
mediaType: oci.image.manifestV1 as string,
config: oci.empty,
layers: [
{
Expand Down Expand Up @@ -83,7 +83,7 @@ describe.concurrent('api v2', async () => {
transport: [
new Unsecure(),
new Accept({
manifests: [oci.image.indexV1],
manifests: [oci.image.manifestV1, oci.image.indexV1],
}),
new FetchTransport(),
],
Expand All @@ -99,7 +99,7 @@ describe.concurrent('api v2', async () => {
await repo.blobs.uploads(oci.empty.digest, Uint8Array.from([...'{}'].map(c => c.charCodeAt(0)))).unwrap()
for (const image of Object.values(images)) {
await repo.blobs.uploads(image.digest, image.bytes).unwrap()
await repo.manifests.put(image.ref, oci.image.ManifestV1 as string, JSON.stringify(image.manifest)).unwrap()
await repo.manifests.put(image.ref, oci.image.manifestV1 as string, JSON.stringify(image.manifest)).unwrap()
}

test(title('end-1', 'GET', '/'), async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/media-types/oci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,5 @@ export namespace image {
subject?: DescriptorV1
annotations?: Record<string, string>
}
export const ManifestV1 = mediaType<ManifestV1>('application/vnd.oci.image.manifest.v1+json')
export const manifestV1 = mediaType<ManifestV1>('application/vnd.oci.image.manifest.v1+json')
}
6 changes: 3 additions & 3 deletions src/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ type As = {
*
* @example
* ```ts
* const res = await client
* const opaque = await client
* .repo('library/node')
* .manifests.get()
* .manifests.get().unwrap()
*
* const v = res.unwrap().as(oci.image.indexV1)
* const v = opaque.as(oci.image.indexV1)
* console.log(v.manifests[0].platform.os) // 'linux'
* ```
*/
Expand Down

0 comments on commit 69524cb

Please sign in to comment.