Skip to content

Add code checker tests in CI and build correct deployment files in CI #435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/actions/run-tests/tests/test-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ cp coverage.integration.xml $GITHUB_WORKSPACE

popd

echo 'Running the code checker'
if ! ./occ app:check-code cookbook; then
echo '::error ::The code checker rejected the code base. See the logs of the action for further details.'
exit 1
fi
echo 'Code checker finished'

echo 'Shutting down temporary web server'
kill $pid

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ jobs:
shell: bash
run: >-
cd nextcloud/apps/cookbook &&
make
make npm composer_dist

- name: Create the source package
shell: bash
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
[#404](https://github.com./nextcloud/cookbook/pull/404) @thembeat
- Replace Default Recipe-Thumb and Full Image with SVG
[#418](https://github.com./nextcloud/cookbook/pull/418) @thembeat
- ENhance the CI tests and build valid dist tarballs during the CI runs
[#435](https://github.com./nextcloud/cookbook/pull/435) @christianlupus

### Fixed
- Add a min PHP restriction in the metadata
Expand Down
29 changes: 25 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,36 @@ ifneq (,$(wildcard $(CURDIR)/js/package.json))
make npm
endif

# Installs and updates the composer dependencies. If composer is not installed
# a copy is fetched from the web
.PHONY: composer
composer:

.PHONY: install_composer
install_composer:
ifeq (, $(composer))
@echo "No composer command available, downloading a copy from the web"
mkdir -p $(build_tools_directory)
curl -sS https://getcomposer.org/installer | php
mv composer.phar $(build_tools_directory)
endif

# Installs and updates the composer dependencies. If composer is not installed
# a copy is fetched from the web
.PHONY: composer
composer: install_composer
ifeq (, $(composer))
php $(build_tools_directory)/composer.phar install --prefer-dist
php $(build_tools_directory)/composer.phar update --prefer-dist
else
composer install --prefer-dist
composer update --prefer-dist
endif

.PHONY: composer_dist
composer_dist: install_composer
ifeq (, $(composer))
php $(build_tools_directory)/composer.phar install --prefer-dist --no-dev
else
composer install --prefer-dist --no-dev
endif

# Installs npm dependencies
.PHONY: npm
npm:
Expand Down Expand Up @@ -132,6 +146,7 @@ appstore:
tar cvzf $(appstore_package_name).tar.gz \
--exclude-vcs \
--exclude="../$(app_name)/build" \
--exclude="../$(app_name)/documentation" \
--exclude="../$(app_name)/tests" \
--exclude="../$(app_name)/Makefile" \
--exclude="../$(app_name)/*.log" \
Expand All @@ -145,11 +160,17 @@ appstore:
--exclude="../$(app_name)/js/bower.json" \
--exclude="../$(app_name)/js/karma.*" \
--exclude="../$(app_name)/js/protractor.*" \
--exclude="../$(app_name)/node_modules" \
--exclude="../$(app_name)/src" \
--exclude="../$(app_name)/translationfiles" \
--exclude="../$(app_name)/draft-release.sh" \
--exclude="../$(app_name)/package.json" \
--exclude="../$(app_name)/package-lock.json" \
--exclude="../$(app_name)/bower.json" \
--exclude="../$(app_name)/karma.*" \
--exclude="../$(app_name)/protractor\.*" \
--exclude="../$(app_name)/.*" \
--exclude="../$(app_name)/webpack.*.js" \
--exclude="../$(app_name)/js/.*" \
../$(app_name)

Expand Down
4 changes: 2 additions & 2 deletions appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
<namespace>Cookbook</namespace>
<category>organization</category>
<website>https://github.com./nextcloud/cookbook/</website>
<screenshot small-thumbnail="https://raw.githubusercontent.com/nextcloud/cookbook/stable/img/screenshot-small.jpg">https://raw.githubusercontent.com/nextcloud/cookbook/stable/img/screenshot-small.jpg</screenshot>
<bugs>https://github.com./nextcloud/cookbook/issues</bugs>
<screenshot small-thumbnail="https://raw.githubusercontent.com/nextcloud/cookbook/stable/img/screenshot-small.jpg">https://raw.githubusercontent.com/nextcloud/cookbook/stable/img/screenshot-small.jpg</screenshot>
<dependencies>
<nextcloud min-version="17" max-version="20"/>
<php min-version="7.2"/>
<nextcloud min-version="17" max-version="20"/>
</dependencies>
<navigations>
<navigation>
Expand Down
2 changes: 1 addition & 1 deletion lib/Db/RecipeDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function findAllCategories(string $user_id) {
public function getRecipesByCategory(string $category, string $user_id) {
$qb = $this->db->getQueryBuilder();

if ($category != '_') {
if ($category !== '_') {
// One would probably want to use GROUP_CONCAT to create the list of keywords
// for the recipe, but those don't seem to work:
// $qb->select(['r.recipe_id', 'r.name', 'GROUP_CONCAT(k.name) AS keywords']) // not working
Expand Down
4 changes: 2 additions & 2 deletions lib/Service/DbCacheService.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ private function isDbEntryUpToDate($id) {
$dbEntry = $this->dbReceipeFiles[$id];
$fileEntry = $this->jsonFiles[$id];

if ($dbEntry['name'] != $fileEntry['name']) {
if ($dbEntry['name'] !== $fileEntry['name']) {
return false;
}

Expand Down Expand Up @@ -238,7 +238,7 @@ private function updateCategories() {

if (isset($this->dbCategories[$rid])) {
// There is a category present. Update needed?
if ($this->dbCategories[$rid] != trim($category)) {
if ($this->dbCategories[$rid] !== trim($category)) {
$this->db->updateCategoryOfRecipe($rid, $category, $this->userId);
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/JsonService.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function isSchemaObject($obj, string $type = null) : bool {
}

// Check if type matches
return (strcmp($obj['@type'], $type) == 0);
return (strcmp($obj['@type'], $type) === 0);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/RecipeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ public function checkRecipe(array $json): array {
// Make sure the 'url' is a URL, or blank
if (isset($json['url']) && $json['url']) {
$url = filter_var($json['url'], FILTER_SANITIZE_URL);
if (filter_var($url, FILTER_VALIDATE_URL) == false) {
if (filter_var($url, FILTER_VALIDATE_URL) === false) {
$url = "";
}
$json['url'] = $url;
Expand Down