-
Notifications
You must be signed in to change notification settings - Fork 25
122 lines (108 loc) · 3.75 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
name: Build
on: push
env:
IMAGE_NAME: ${{ github.repository }}
TEST_TAG: user/app:test
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: echo Using node version $(node --version)
- run: echo Using npm version $(npm --version)
- run: cp .env.example .env
- run: cp test/data/ttl/interactivityType.ttl data/
- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
name: List the state of node modules
continue-on-error: true
run: npm list
- run: npm install
- run: npm run build --if-present
- run: npm run test
# disables because the action fails on github action but tests works locally
e2e:
runs-on: ubuntu-22.04
container:
image: cypress/browsers:node-20.9.0-chrome-118.0.5993.88-1-ff-118.0.2-edge-118.0.2088.46-1
strategy:
matrix:
node-version: [18.x]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: echo Using node version $(node --version)
- run: echo Using npm version $(npm --version)
- run: cypress/prepare-cypress-test.sh
- name: Cypress run
uses: cypress-io/github-action@v6
with:
headed: true
start: npm run develop -- -p 8000
wait-on: 'http://0.0.0.0:8000' # see https://github.com/cypress-io/github-action#wait-on-with-nodejs-18
config: baseUrl=http://localhost:8000
docker:
needs: [build, e2e]
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: skohub/skohub-vocabs-docker
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}#
type=raw,value=dev,enable=${{ github.ref == format('refs/heads/{0}', 'dev') }}
- name: Build and export to Docker
uses: docker/build-push-action@v3
with:
context: .
load: true
tags: ${{ env.TEST_TAG }}
- name: Test docker image
run: |
mkdir -p data
cp .env.example .env
cp test/data/ttl/interactivityType.ttl data/
docker run --rm -v $(pwd)/data:/app/data -v $(pwd)/.env:/app/.env ${{ env.TEST_TAG }}
- name: Build and push
uses: docker/build-push-action@v3
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}