Skip to content

Commit

Permalink
Merge branch 'release/1.2.2' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymillergh committed Oct 27, 2020
2 parents 008741b + cc9633d commit 23b751f
Show file tree
Hide file tree
Showing 26 changed files with 571 additions and 84 deletions.
13 changes: 8 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ jdk: oraclejdk11
# https://docs.travis-ci.com/user/job-lifecycle#skipping-the-installation-phase
install: skip

# To prevent error like:
# Grant execute permission to prevent error like:
# xxx.sh: Permission denied
before_script:
- chmod +x .travis/common.sh
- source ./.travis/common.sh
- 'printInfo "[INSTALL] Grant execute permission"'
- chmod +x .travis/install.sh
- chmod +x .travis/deploy.sh
- chmod +x mvnw
Expand All @@ -28,17 +31,17 @@ script:
# Decrypt file `gpg.asc.enc` before deployment
# https://docs.travis-ci.com/user/encrypting-files/
before_deploy:
- 'printWarn "[DEPLOY] TRAVIS_BRANCH: $TRAVIS_BRANCH"'
- 'printWarn "[DEPLOY] TRAVIS_TAG: $TRAVIS_TAG"'
- openssl aes-256-cbc -K $encrypted_4f0d00631887_key -iv $encrypted_4f0d00631887_iv -in .travis/gpg.asc.enc -out .travis/gpg.asc -d

deploy:
- skip_cleanup: true
provider: script
script: ./.travis/deploy.sh
on:
branch:
- feature/**
- release/**
- hotfix/**
all_branches: true
condition: $TRAVIS_BRANCH =~ ^(feature|release|hotfix)\/.*$
- skip_cleanup: true
provider: script
script: ./.travis/deploy.sh
Expand Down
26 changes: 26 additions & 0 deletions .travis/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

########################## Functions Declaration ##########################
# Bash tips: Colors and formatting (ANSI/VT100 Control sequences)
# https://misc.flogisoft.com/bash/tip_colors_and_formatting
# Pass arguments into a function
# https://bash.cyberciti.biz/guide/Pass_arguments_into_a_function
function now() {
nowVariable=$(date +%Y-%m-%d' '%H:%M:%S.%N | cut -b 1-23)
echo "$nowVariable"
}

function printInfo() {
echo -e "$(now) \e[32mINFO --- $1\e[0m"
return 0
}

function printWarn() {
echo -e "$(now) \e[33mWARN --- $1\e[0m"
return 0
}

function printError() {
echo -e "$(now) \e[31mERROR --- $1\e[0m"
return 0
}
32 changes: 23 additions & 9 deletions .travis/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,63 @@
# expects file to exist:
# - .travis/gpg.asc

# Exit immediately if a command exits with a non-zero status.
# https://stackoverflow.com/questions/19622198/what-does-set-e-mean-in-a-bash-script
set -e

########################## Functions Import ##########################
source ./.travis/common.sh

# Check the variables are set
if [ -z "$OSSRH_USERNAME" ]; then
echo "[Deployment] ERROR - Missing environment value: OSSRH_USERNAME" >&2
printError "[DEPLOY] Missing environment value: OSSRH_USERNAME" >&2
exit 1
fi

if [ -z "$OSSRH_PASSWORD" ]; then
echo "[Deployment] ERROR - Missing environment value: OSSRH_PASSWORD" >&2
printError "[DEPLOY] Missing environment value: OSSRH_PASSWORD" >&2
exit 1
fi

if [ -z "$GPG_KEY_NAME" ]; then
echo "[Deployment] ERROR - Missing environment value: GPG_KEY_NAME" >&2
printError "[DEPLOY] Missing environment value: GPG_KEY_NAME" >&2
exit 1
fi

if [ -z "$GPG_PASSPHRASE" ]; then
echo "[Deployment] ERROR - Missing environment value: GPG_PASSPHRASE" >&2
printError "[DEPLOY] Missing environment value: GPG_PASSPHRASE" >&2
exit 1
fi

echo "[Deployment] INFO - All expected variables are set. OSSRH_USERNAME, OSSRH_PASSWORD, GPG_KEY_NAME and GPG_PASSPHRASE"
printInfo "[DEPLOY] All expected variables are set. OSSRH_USERNAME, OSSRH_PASSWORD, GPG_KEY_NAME and GPG_PASSPHRASE"

# If decrypted file .travis/gpg.asc not exists
if [ ! -f "${TRAVIS_BUILD_DIR}/.travis/gpg.asc" ]; then
echo "[Deployment] ERROR - Missing decrypted file: .travis/gpg.asc" >&2
printError "[DEPLOY] Missing decrypted file: .travis/gpg.asc" >&2
exit 1
else
echo "[Deployment] INFO - Found decrypted file: .travis/gpg.asc"
printInfo "[DEPLOY] Found decrypted file: .travis/gpg.asc"
fi

# Prepare the local keyring (requires travis to have decrypted the file beforehand)
gpg --fast-import .travis/gpg.asc

# If `TRAVIS_TAG` string is not empty
if [ -n "$TRAVIS_TAG" ]; then
echo "[Deployment] INFO - Maven deploy on a tag -> set pom.xml <version> to TRAVIS_TAG: $TRAVIS_TAG"
printWarn "[DEPLOY] Maven deploy on a tag -> set pom.xml <version> to TRAVIS_TAG: $TRAVIS_TAG"
mvn --settings "${TRAVIS_BUILD_DIR}/.travis/maven-settings.xml" org.codehaus.mojo:versions-maven-plugin:2.7:set -DnewVersion=$TRAVIS_TAG 1>/dev/null 2>/dev/null
else
echo "[Deployment] INFO - Maven deploy not on a tag -> keep snapshot version in pom.xml"
printWarn "[DEPLOY] Maven deploy not on a tag -> keep snapshot version in pom.xml"
fi

# Run the maven deploy steps
mvn deploy -P publish -DskipTests=true --quiet --settings "${TRAVIS_BUILD_DIR}/.travis/maven-settings.xml"

DEPLOY_COMMAND_RESULT=$?

if [ "$DEPLOY_COMMAND_RESULT" -eq 0 ]; then
printInfo "[DEPLOY] Deployment succeed. DEPLOY_COMMAND_RESULT: $DEPLOY_COMMAND_RESULT"
else
printError "[DEPLOY] Deployment failed. DEPLOY_COMMAND_RESULT: $DEPLOY_COMMAND_RESULT" >&2
exit 1
fi
23 changes: 22 additions & 1 deletion .travis/install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
#!/bin/bash

# Run the maven install
# Exit immediately if a command exits with a non-zero status.
# https://stackoverflow.com/questions/19622198/what-does-set-e-mean-in-a-bash-script
set -e

########################## Functions Import ##########################
source ./.travis/common.sh

CURRENT_DIR=$(pwd)
printInfo "[INSTALL] CURRENT_DIR: $CURRENT_DIR"
printInfo "[INSTALL] List of CURRENT_DIR:"
command "ls"

# Run the Maven clean install
./mvnw clean install -Dmaven.javadoc.skip=true -Dgpg.skip=true --quiet --batch-mode --show-version

INSTALL_COMMAND_RESULT=$?

if [ "$INSTALL_COMMAND_RESULT" -eq 0 ]; then
printInfo "[INSTALL] Installation succeed. INSTALL_COMMAND_RESULT: $INSTALL_COMMAND_RESULT"
else
printError "[INSTALL] Installation failed. INSTALL_COMMAND_RESULT: $INSTALL_COMMAND_RESULT" >&2
exit 1
fi
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,40 @@
# [1.2.2](https://github.com/johnnymillergh/media-streaming/compare/v1.2.1...1.2.2) (2020-10-27)


### Features

* **MediaInfo:** support get media info ([23249f1](https://github.com/johnnymillergh/media-streaming/commit/23249f14f25390a3bf582a4f5dfd75a7201a194a))
* **Webflux:** migrate to annotation based Webflux ([65b2dbf](https://github.com/johnnymillergh/media-streaming/commit/65b2dbf3636be215ff83e8f0d1ce8a254444693c))


### Performance Improvements

* **Bash:** abstract functions into common.sh ([5e3fc6f](https://github.com/johnnymillergh/media-streaming/commit/5e3fc6f8d3e78d4b0e253010309b00731424ce85))
* **Concurrency:** improve Java object lock for FileWatcher::terminate() ([fe41844](https://github.com/johnnymillergh/media-streaming/commit/fe418446c2440cb41f76a3d36b7e8f82e95ac54d))
* **FileWatcher:** capture ClosedWatchServiceException ([cf8f4ca](https://github.com/johnnymillergh/media-streaming/commit/cf8f4caea0e92ab9a68470023d9e37fed16f1962))
* **FileWatcher:** close WatchService synchronously ([2e28596](https://github.com/johnnymillergh/media-streaming/commit/2e285961e1f136b860f1b1b8bbb53707243e2ead))
* **FileWatcher:** gracefully destroy FileWatcher ([f1b9720](https://github.com/johnnymillergh/media-streaming/commit/f1b972091434903526d5b5e4807c96ddf5487acb))
* **FileWatcher:** recursively monitor directory ([2195010](https://github.com/johnnymillergh/media-streaming/commit/2195010cecfa9a3f21ea015fee736c299a9d0d85))
* **Travis:** beautify bash command ([5750e06](https://github.com/johnnymillergh/media-streaming/commit/5750e06e4624146c112ce6ebc2e983d2c1b8220a))
* **Travis:** colorize bash command ([b6bd88d](https://github.com/johnnymillergh/media-streaming/commit/b6bd88d8904f265f9696a3111af6375583036ff5))
* **Travis:** display timestamp ([037e9b1](https://github.com/johnnymillergh/media-streaming/commit/037e9b1ce663cc54080a98fa8c9365ed9a5e51ab))
* **Travis:** make bash message bold ([73b7d97](https://github.com/johnnymillergh/media-streaming/commit/73b7d9798d15b3168b8b70b83d0fa3dd0b33ad4d))


### Reverts

* **Travis:** uncomment 'set -e' ([b4da625](https://github.com/johnnymillergh/media-streaming/commit/b4da62552d98d641887e7b4028b85cc56b5a7df9))


### BREAKING CHANGES

* **Concurrency:** improve Java object lock for FileWatcher::terminate()
* **FileWatcher:** recursively monitor directory; fixed file not deleted
under sub directory problem
* **Webflux:** migrate to annotation based Webflux



# [1.2.0](https://github.com/johnnymillergh/media-streaming/compare/v1.1.1...1.2.0) (2020-10-22)


Expand Down
43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The easiest way is to install the library via [Nexus Repository Manager](https:/
<dependency>
<groupId>com.github.johnnymillergh.boot</groupId>
<artifactId>media-streaming-spring-boot-starter</artifactId>
<version>1.2.0-SNAPSHOT</version>
<version>1.2.2</version>
</dependency>
```

Expand All @@ -59,6 +59,47 @@ Alternatively, download it from the [releases page](https://github.com/johnnymil

3. Click the green triangle to Run.

## Useful Commands

### Maven

1. Set project version:

```shell
mvn versions:set -DgenerateBackupPoms=false -f pom.xml
```

2. Build project:

```shell
mvn clean validate compile -f pom.xml
```

### Conventional Changelog CLI

1. Install global dependencies (optional if installed):

```shell
npm install -g conventional-changelog-cli
```

2. This will *not* overwrite any previous changelogs. The above generates a changelog based on commits since the last semver tag that matches the pattern of "Feature", "Fix", "Performance Improvement" or "Breaking Changes".

```shell
conventional-changelog -p angular -i CHANGELOG.md -s
```

3. If this is your first time using this tool and you want to generate all previous changelogs, you could do:

```
conventional-changelog -p angular -i CHANGELOG.md -s -r 0
```

## CI (Continuous Integration)

- [Travis CI](https://travis-ci.com/github/johnnymillergh/media-streaming) is for deploying SNAPSHOT and RELEASE on Nexus Central Repository.
- [GitHub Actions](https://github.com/johnnymillergh/media-streaming/actions) is for checking dependency updates and tests.

## Maintainers

[@johnnymillergh](https://github.com/johnnymillergh).
Expand Down
2 changes: 1 addition & 1 deletion media-streaming-sample-app/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.github.johnnymillergh.boot</groupId>
<artifactId>media-streaming</artifactId>
<version>1.2.0</version>
<version>1.2.2-SNAPSHOT</version>
</parent>
<artifactId>media-streaming-sample-app</artifactId>
<name>Media Streaming :: Sample App</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.johnnymillergh.boot.mediastreamingsampleapp;

import com.github.johnnymillergh.boot.mediastreamingspringbootautoconfigure.model.Video;
import com.github.johnnymillergh.boot.mediastreamingspringbootautoconfigure.handler.VideoRouteHandler;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -26,14 +26,14 @@ class MediaStreamingSampleAppApplicationTests {

@Test
void videosTest() {
EntityExchangeResult<List<Video>> returnResult = webTestClient
EntityExchangeResult<List<VideoRouteHandler.VideoDetails>> returnResult = webTestClient
.get()
.uri("/videos")
.accept(MediaType.ALL)
.exchange()
.expectStatus()
.isOk()
.expectBodyList(Video.class)
.expectBodyList(VideoRouteHandler.VideoDetails.class)
.returnResult();
log.info("Video test: {}", returnResult.getResponseBody());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.github.johnnymillergh.boot.mediastreamingsampleapp.api;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.reactive.AutoConfigureWebTestClient;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.web.reactive.server.WebTestClient;

import java.util.UUID;

/**
* Description: ApiTests, change description here.
*
* @author Johnny Miller (锺俊), email: [email protected], date: 10/27/2020 4:36 PM
**/
@Slf4j
@SpringBootTest
@AutoConfigureWebTestClient
public class MediaStreamingReactiveApiTests {
@Autowired
private WebTestClient webTestClient;

@Test
void getVideoAnnotationBased() {
webTestClient
.get()
.uri("/video-annotation")
.accept(MediaType.ALL)
.exchange()
.expectStatus()
.isOk();
log.info("getVideoAnnotationBased passed");
}

@Test
void mediaInfo() {
webTestClient
.get()
.uri(String.format("/media-info/%s.mp4", UUID.randomUUID()))
.accept(MediaType.APPLICATION_JSON)
.exchange()
.expectStatus()
.is4xxClientError();
log.info("mediaInfo passed.");
}
}
2 changes: 1 addition & 1 deletion media-streaming-spring-boot-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.github.johnnymillergh.boot</groupId>
<artifactId>media-streaming</artifactId>
<version>1.2.0</version>
<version>1.2.2-SNAPSHOT</version>
</parent>
<artifactId>media-streaming-spring-boot-autoconfigure</artifactId>
<name>Media Streaming :: Spring Boot Autoconfigure</name>
Expand Down
Loading

0 comments on commit 23b751f

Please sign in to comment.