diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 00000000..8e6955ca --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,8 @@ +ARG JAVA_VERSION=8 +FROM eclipse-temurin:${JAVA_VERSION}-jdk-jammy + +RUN groupadd --gid 1000 vscode \ + && useradd --uid 1000 --gid 1000 --create-home --shell /bin/bash vscode \ + && apt-get update \ + && apt-get install -y --no-install-recommends curl git openssh-client \ + && rm -rf /var/lib/apt/lists/* diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..0d14d04f --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,20 @@ +{ + "name": "contentful.java", + "build": { + "dockerfile": "Dockerfile", + "context": "..", + "args": { + "JAVA_VERSION": "${localEnv:JAVA_VERSION:8}" + } + }, + "workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}", + "remoteUser": "vscode", + "postCreateCommand": "./mvnw -B -q -DskipTests dependency:go-offline", + "customizations": { + "vscode": { + "extensions": [ + "redhat.java" + ] + } + } +} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..b356adab --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,27 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + branches: [master] + +permissions: + contents: read + +jobs: + test: + name: Test (Java 8) + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + + - name: Install devcontainer CLI + run: npm install -g @devcontainers/cli@0 + + - name: Run tests in dev container + env: + JAVA_VERSION: "8" + run: | + devcontainer up --workspace-folder . + devcontainer exec --workspace-folder . bash -lc "./mvnw -B test" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index de95c079..00000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,32 +0,0 @@ ---- -name: "CodeQL Scan for GitHub Actions Workflows" - -on: - push: - branches: [master] - paths: [".github/workflows/**"] - pull_request: - branches: [master] - paths: [".github/workflows/**"] - -jobs: - analyze: - name: Analyze GitHub Actions workflows - runs-on: ubuntu-latest - permissions: - actions: read - contents: read - security-events: write - - steps: - - uses: actions/checkout@v4 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: actions - - - name: Run CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: actions diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4e1d45dd..00000000 --- a/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -sudo: false -language: java - -dist: trusty - -jdk: - - oraclejdk8 - - openjdk8 - -script: - - mvn jacoco:prepare-agent test jacoco:report - -after_success: - - .buildscript/deploy_snapshot.sh - - .buildscript/integration_tests.sh - -env: - global: - - secure: ZkYu76rxDUUgoUSIz12CReNZHd2c5O2LBWCHnuQpqfJfcCXBr1J24F7WftiFXH+9Od43qHdF4hQ9Vy0vWEHSJ1hxZnCIy5yYsvqV4GJ94DIJhvNqmo48QPkA3tFUsqd48rEeBXMUsON30m89KDp1se2+l3UJaX+R27RUi47nraU= - - secure: jKXD1hYVgJypaQHRSm4gshxMhB+T+UibaLDLCSfGWSaGzogDsWnPXf9qqG3jtozKHyH0BkANaaO6rRgNQNfbaklm4jopL1bdRkd47JO/nibNwuVcG07TQyCPQR6jv/WoRAkxXOGdMSwwS2+puM7FJqLarbzY7uBEJtNsZn5JT48= - - secure: k2FkpJUg0FxfTeTadPc4xDA7xPmheZg6+u4DLn7kRP3bfHNG8lP57pYq/b1iDN+3VBXOkQtGttUyS1EExUubmeoQk4JwOUuePv6Ru24Mi5YoEdlkBzu2KZXV0o7aZZookYdsQTOQ/Jd576sn3oiXbAtW6n93h7h6SRCFIAG/nmc= - - -branches: - except: - - gh-pages - -notifications: - slack: - - secure: Wq9lfTl+SSlfe+4OSLIINsUJZKEN0jYC07nI6PL1Sv4wZCUHmkvXNvsDj+0QLYkKkdEao2Yg3CLHSU5GdvZ2eQpY1mut6i+DxUHnICDQp6liS73UfW3KZIw7zkAMrlXYgVKtIUCUVjZFVyZ7AOxdt8Z6y5oKuXQiGC6h8vmi2Qk= diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..448f9772 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,32 @@ +# Contributing + +Thanks for helping improve `contentful.java`. + +## Development with Dev Containers + +This repository includes a `.devcontainer` configuration for a reproducible local setup. GitHub Actions uses the same devcontainer configuration for CI. + +### Visual Studio Code + +Open the repository in Visual Studio Code, install the Dev Containers extension if needed, then run `Dev Containers: Reopen in Container`. Wait for the container build and post-create setup to finish. + +### Terminal or other editors + +Install Docker and the Dev Container CLI (`npm install -g @devcontainers/cli`). From the repository root, run: + +```bash +devcontainer up --workspace-folder . +devcontainer exec --workspace-folder . bash +``` + +### Verify the environment + +```bash +./mvnw -B test +``` + +## Pull Requests + +1. Fork the repository and create a branch for your change. +2. Run the relevant checks from the dev container. +3. Open a pull request with a short summary of the change and any follow-up context. diff --git a/README.md b/README.md index 61083b17..f7cf6313 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ contentful.java - Contentful Java Delivery Library ================================================== -[![Build Status](https://travis-ci.org/contentful/contentful.java.svg)](https://travis-ci.org/contentful/contentful.java/builds#) +[![CI](https://github.com/contentful/contentful.java/actions/workflows/ci.yml/badge.svg)](https://github.com/contentful/contentful.java/actions/workflows/ci.yml) > Java library for [Content Delivery API](https://www.contentful.com/developers/docs/references/content-delivery-api/) and [Content Preview API](https://www.contentful.com/developers/docs/references/content-preview-api/). It helps in easily accessing the content stored in Contentful using Java applications. @@ -513,6 +513,16 @@ Getting involved [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?maxAge=31557600)](http://makeapullrequest.com) +For a reproducible local setup, open this repository in its included dev container. The container installs the project dependencies automatically when it is created. + +After the container is ready, run: + +```bash +./mvnw -B test +``` + +See [CONTRIBUTING.md](CONTRIBUTING.md) for the full contributor workflow. + Code of Conduct ===============