Skip to content

Commit

Permalink
Merge pull request #63 from funidata/devops
Browse files Browse the repository at this point in the history
Activate release pipeline
  • Loading branch information
joonashak authored Jun 21, 2023
2 parents 3e1ae80 + 4b843ad commit 09bc1e7
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 90 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ jobs:
docker tag hybridilusmu ghcr.io/funidata/hybridilusmu:${{ steps.semver.outputs.version }}
docker tag hybridilusmu ghcr.io/funidata/hybridilusmu:latest
- name: Push image to GHCR
run: docker push ghcr.io/funidata/hybridilusmu:next
run: docker push --all-tags ghcr.io/funidata/hybridilusmu
39 changes: 1 addition & 38 deletions .github/workflows/run_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
run: npm run init
- name: Lint E2E tests
working-directory: e2e
run: npm run lint
run: echo "Not implemented"

unit-tests:
name: Unit tests
Expand All @@ -40,43 +40,6 @@ jobs:
- name: Stop containers
if: always()
run: npm stop

# e2e-tests:
# name: E2E tests
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2
# - name: Download artifact
# uses: actions/download-artifact@v3
# with:
# name: hybridilusmu
# path: /tmp
# - name: Load image
# run: |
# docker load --input /tmp/hybridilusmu.tar
# docker image ls -a
# - name: Build E2E container
# run: docker compose -f compose.yaml -f compose-ci.yaml build e2e
# - name: Start containers
# run: docker compose -f compose.yaml -f compose-ci.yaml up -d lusmu
# - name: Run E2E tests
# env:
# CYPRESS_BASE_URL: ${{ vars.CYPRESS_BASE_URL }}
# run: npm run e2e:ci
# - name: Save Results
# uses: actions/upload-artifact@v2
# if: failure()
# with:
# name: Cypress Results
# path: |
# e2e/cypress/videos
# e2e/cypress/screenshots
# - name: Stop containers
# if: always()
# run: npm stop
# FIXME: Enable these once integration tests exit cleanly.
# integration-tests:
# name: Integration tests
Expand Down
4 changes: 2 additions & 2 deletions app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hybridilusmu",
"version": "1.0.0",
"version": "0.0.2",
"engines": {
"npm": ">=9.5.1",
"node": ">=18.16.0"
Expand Down Expand Up @@ -38,4 +38,4 @@
"nodemon": "^2.0.22",
"nyc": "^15.1.0"
}
}
}
4 changes: 0 additions & 4 deletions compose-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
services:
lusmu:
image: hybridilusmu-ci

e2e:
environment:
- CYPRESS_BASE_URL=$CYPRESS_BASE_URL
4 changes: 0 additions & 4 deletions compose-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,3 @@ services:
env_file:
- .env.development
command: npm run watch

e2e:
env_file:
- .env.development
6 changes: 0 additions & 6 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,3 @@ services:
POSTGRES_PASSWORD: postgres
volumes:
- lusmu-db:/var/lib/postgresql/data

e2e:
container_name: lusmu-e2e
build: e2e/
volumes:
- ./e2e/cypress:/e2e/cypress
4 changes: 0 additions & 4 deletions dev/.codecov.yml

This file was deleted.

22 changes: 0 additions & 22 deletions dev/.eslintrc.js

This file was deleted.

19 changes: 19 additions & 0 deletions docs/Releases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Releases

Releases are automatically build and published as [`hybridilusmu`](https://github.com/funidata/hybridilusmu/pkgs/container/hybridilusmu) to GitHub Container Registry.

## Stable Release

A stable release is tagged with `npm version` and after merging to `main`, the stable release workflow is triggered by publishing a [GitHub release](https://github.com/funidata/hybridilusmu/releases/new).

An example workflow:

1. Make sure your local branch is clean.
2. Run `npm version <major|minor|patch>` in repo root. This bumps the version in all NPM projects, commits the changes, creates a new tag and pushes tags to GitHub. Only the tags are pushed automatically and it does not matter whether or not your actual branch has been pushed to `origin`. You will need to push the actual commits as usual.
3. Have the branch reviewed and merged into `main`.
4. [Create a new release](https://github.com/funidata/hybridilusmu/releases/new) on GitHub, choosing your new tag as the source. You can use the tag's name as release title or come up with something better.
5. Upon clicking Publish Release, the stable release workflow is triggered. It builds the image from the chosen tag, requires all tests to pass, and published the image to GHCR upon success.

## Unstable Release

The head of `main` branch is published on every push with the `next` tag.
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hybridilusmu-dev-env",
"version": "0.0.1",
"version": "0.0.2",
"engines": {
"npm": ">=9.5.1",
"node": ">=18.16.0"
Expand All @@ -9,14 +9,16 @@
"start": "docker compose -f compose.yaml -f compose-dev.yaml up -d --build lusmu",
"stop": "docker compose down",
"logs": "docker compose logs -f",
"init": "cd app && npm ci && cd ../e2e && npm ci",
"init": "cd app && npm ci",
"test": "docker exec -t lusmu-dev npm test",
"test:integration": "docker exec -t lusmu-dev npm run test:integration",
"test:all": "npm test && npm test:integration && npm e2e:run",
"test:all": "npm test && npm test:integration",
"e2e:run": "set -o allexport && source .env.development && set +o allexport && cd e2e && npm test",
"e2e:open": "set -o allexport && source .env.development && set +o allexport && cd e2e && npm start",
"e2e:docker": "docker compose -f compose.yaml -f compose-dev.yaml run --build e2e cypress run",
"e2e:ci": "docker compose -f compose.yaml -f compose-ci.yaml run e2e cypress run"
"e2e:ci": "docker compose -f compose.yaml -f compose-ci.yaml run e2e cypress run",
"version": "scripts/version_sub_projects.sh $npm_package_version",
"postversion": "git push --tags"
},
"license": "MIT"
}
31 changes: 31 additions & 0 deletions scripts/version_sub_projects.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# Sync sub-projects to given version number.
#
# Pass current version as first argument.
# This script is meant to be used along with `npm version` in project root.

# List projects to update here by their folder name.
projects=(
"app"
)

new_version=$1
project_root=$(pwd)

function update_sub_project_version {
project_name=$1
dir="${project_root}/${project_name}"

cd $dir
echo -n "${project_name}: "

# Don't commit, just bump to given version.
npm version --git-tag-version false $new_version
# Running `npm version` in root will not stage extra files, so add them here.
git add "${dir}/package.json" "${dir}/package-lock.json"
}

for project in ${projects[@]}; do
update_sub_project_version $project
done
3 changes: 0 additions & 3 deletions tsconfig.json

This file was deleted.

0 comments on commit 09bc1e7

Please sign in to comment.