diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 00000000..d6bdbc2e --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,39 @@ +name: validate +on: + push: + branches: + - 'main' + pull_request: + branches: + - '**' +jobs: + tests: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + - uses: actions/setup-node@v6 + with: + node-version-file: '.nvmrc' + - run: make validate.ci + - name: Archive code coverage results + uses: actions/upload-artifact@v6 + with: + name: code-coverage-report + path: coverage/*.* + coverage: + runs-on: ubuntu-latest + needs: tests + steps: + - uses: actions/checkout@v6 + - name: Download code coverage results + uses: actions/download-artifact@v7 + with: + pattern: code-coverage-report + path: coverage + merge-multiple: true + - name: Upload coverage + uses: codecov/codecov-action@v5 + with: + fail_ci_if_error: true + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/Makefile b/Makefile index 1cfc7a0b..8df4ad30 100644 --- a/Makefile +++ b/Makefile @@ -52,3 +52,20 @@ build: clean mkdir -p "$$(dirname "$$d")"; \ cp "$$f" "$$d"; \ done' sh {} + + +validate-no-uncommitted-package-lock-changes: + # Checking for package-lock.json changes... + git diff --exit-code package-lock.json + +.PHONY: validate +validate: + make validate-no-uncommitted-package-lock-changes + npm run i18n_extract + npm run lint -- --max-warnings 0 + npm run test:ci + npm run build + +.PHONY: validate.ci +validate.ci: + npm ci + make validate \ No newline at end of file diff --git a/package.json b/package.json index b67246d3..9ba7f984 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,8 @@ "lint:fix": "openedx lint --fix .", "prepack": "npm run build", "snapshot": "openedx test --updateSnapshot", - "test": "openedx test --coverage --passWithNoTests" + "test": "openedx test --coverage --passWithNoTests", + "test:ci": "TZ=UTC fedx-scripts jest --silent --coverage --passWithNoTests" }, "author": "Open edX", "license": "AGPL-3.0",