Skip to content
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

Update config for new structure #14

Merged
merged 7 commits into from
Jun 7, 2024
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: 3 additions & 4 deletions .github/workflows/Docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ on:
branches: [ main ]

env:
# TODO: Change variable to your registry.
REGISTRY_NAME: hexletbasics

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Check image building
run: docker build .

Expand All @@ -23,12 +22,12 @@ jobs:
if: ${{ github.event_name == 'push' }}
needs: build
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set repository name
run: |
echo "REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}')" >> $GITHUB_ENV
- name: Build and push into docker hub
uses: docker/build-push-action@v1.1.0
uses: docker/build-push-action@v5
with:
repository: ${{ env.REGISTRY_NAME }}/${{ env.REPOSITORY_NAME }}
username: ${{ secrets.DOCKER_USERNAME }}
Expand Down
7 changes: 2 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@ ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV DEBIAN_FRONTEND noninteractive

ENV INVALIDATE_CACHE 1

RUN apt-get update
RUN apt-get install -yqq \
RUN apt-get update && apt-get install -yqq \
git curl python3-pip libyaml-dev zip unzip jq software-properties-common wget
RUN pip3 install yamllint yq
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - && apt-get install -y nodejs
RUN curl -sL https://deb.nodesource.com/setup_20.x | bash - && apt-get install -y nodejs
RUN npm install -g ajv-cli

COPY ./common /opt/basics/common
5 changes: 5 additions & 0 deletions common/bin/validate-language.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

find . -mindepth 1 -maxdepth 1 -name 'description.*.yml' -print0 | while IFS= read -r -d '' file; do
ajv -s /opt/basics/common/language.json -d $file || exit 1
done
5 changes: 5 additions & 0 deletions common/bin/validate-lessons.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

find modules -mindepth 4 -maxdepth 4 -name 'data.yml' -print0 | while IFS= read -r -d '' file; do
ajv -s /opt/basics/common/lesson.json -d $file || exit 1
done
5 changes: 5 additions & 0 deletions common/bin/validate-modules.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

find modules -mindepth 2 -maxdepth 2 -name 'description.*.yml' -print0 | while IFS= read -r -d '' file; do
ajv -s /opt/basics/common/module.json -d $file || exit 1
done
5 changes: 5 additions & 0 deletions common/bin/validate-spec.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

find . -mindepth 1 -maxdepth 1 -name 'spec.yml' -print0 | while IFS= read -r -d '' file; do
ajv -s /opt/basics/common/spec.json -d $file || exit 1
done
19 changes: 10 additions & 9 deletions common/common.mk
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
COMMON_DIR := /opt/basics/common

check: description-lint code-lint schema-validate test

description-lint:
yamllint modules
yamllint modules -c $(COMMON_DIR)/yamllint.yml

test:
@(for i in $$(find modules/** -type f -name Makefile); do make test -C $$(dirname $$i) || exit 1; done)

# TODO: add markdown linter and spellckeck (languagetool)
schema-validate:
@$(COMMON_DIR)/bin/validate-spec.sh
@$(COMMON_DIR)/bin/validate-language.sh
@$(COMMON_DIR)/bin/validate-modules.sh
@$(COMMON_DIR)/bin/validate-lessons.sh

SUBDIRS := $(wildcard modules/**/*/.)

schema-validate: $(SUBDIRS)
$(SUBDIRS):
yq . $@/description.ru.yml > /tmp/current-description.json && ajv -s /opt/basics/common/schema.json -d /tmp/current-description.json
yq . $@/description.en.yml > /tmp/current-description.json && ajv -s /opt/basics/common/schema.json -d /tmp/current-description.json || true

.PHONY: all test $(SUBDIRS)
.PHONY: all test
32 changes: 32 additions & 0 deletions common/language.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "schema.json",
"description": "description schema",
"title": "Language",
"type": "object",
"properties": {
"title": {
"type": "string"
},
"header": {
"type": "string"
},
"description": {
"type": "string"
},
"seo_description": {
"type": "string"
},
"keywords": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"title",
"description"
],
"additionalProperties": false
}
41 changes: 41 additions & 0 deletions common/lesson.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "schema.json",
"description": "description schema",
"title": "Lesson",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"tips": {
"type": "array",
"items": {
"type": "string"
}
},
"definitions": {
"type": "array",
"items": {
"additionalProperties": false,
"type": "object",
"required": [
"name",
"description"
],
"properties": {
"name": {
"type": "string"
},
"description": {
"type": "string"
}
}
}
}
},
"required": [
"name"
],
"additionalProperties": false
}
20 changes: 20 additions & 0 deletions common/module.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "schema.json",
"description": "description schema",
"title": "Module",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"description": {
"type": "string"
}
},
"required": [
"name",
"description"
],
"additionalProperties": false
}
16 changes: 0 additions & 16 deletions common/schema.json

This file was deleted.

46 changes: 46 additions & 0 deletions common/spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "schema.json",
"description": "description schema",
"title": "Module",
"type": "object",
"properties": {
"language": {
"type": "object",
"additionalProperties": false,
"required": [
"docker_image",
"extension",
"exercise_filename",
"exercise_test_filename",
"learn_as",
"progress",
"name"
],
"properties": {
"docker_image": {
"type": "string"
},
"extension": {
"type": "string"
},
"exercise_filename": {
"type": "string"
},
"exercise_test_filename": {
"type": "string"
},
"learn_as": {
"type": "string"
},
"progress": {
"type": "string"
},
"name": {
"type": "string"
}
}
}
},
"additionalProperties": false
}
5 changes: 5 additions & 0 deletions common/yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
extends: default

rules:
line-length: disable