diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 219074780e3..00000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,212 +0,0 @@ -# DSpace Continuous Integration/Build via GitHub Actions -# Concepts borrowed from -# https://docs.github.com/en/free-pro-team@latest/actions/guides/building-and-testing-nodejs -name: Build - -# Run this Build for all pushes / PRs to current branch -on: [push, pull_request] - -permissions: - contents: read # to fetch code (actions/checkout) - -jobs: - tests: - runs-on: ubuntu-latest - env: - # The ci step will test the dspace-angular code against DSpace REST. - # Direct that step to utilize a DSpace REST service that has been started in docker. - # NOTE: These settings should be kept in sync with those in [src]/docker/docker-compose-ci.yml - DSPACE_REST_HOST: 127.0.0.1 - DSPACE_REST_PORT: 8080 - DSPACE_REST_NAMESPACE: '/server' - DSPACE_REST_SSL: false - # Spin up UI on 127.0.0.1 to avoid host resolution issues in e2e tests with Node 18+ - DSPACE_UI_HOST: 127.0.0.1 - DSPACE_UI_PORT: 4000 - # Ensure all SSR caching is disabled in test environment - DSPACE_CACHE_SERVERSIDE_BOTCACHE_MAX: 0 - DSPACE_CACHE_SERVERSIDE_ANONYMOUSCACHE_MAX: 0 - # Tell Cypress to run e2e tests using the same UI URL - CYPRESS_BASE_URL: http://127.0.0.1:4000 - # When Chrome version is specified, we pin to a specific version of Chrome - # Comment this out to use the latest release - #CHROME_VERSION: "90.0.4430.212-1" - # Bump Node heap size (OOM in CI after upgrading to Angular 15) - NODE_OPTIONS: '--max-old-space-size=4096' - strategy: - # Create a matrix of Node versions to test against (in parallel) - matrix: - node-version: [16.x, 18.x] - # Do NOT exit immediately if one matrix job fails - fail-fast: false - # These are the actual CI steps to perform per job - steps: - # https://github.com/actions/checkout - - name: Checkout codebase - uses: actions/checkout@v3 - - # https://github.com/actions/setup-node - - name: Install Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 - with: - node-version: ${{ matrix.node-version }} - - # If CHROME_VERSION env variable specified above, then pin to that version. - # Otherwise, just install latest version of Chrome. - - name: Install Chrome (for e2e tests) - run: | - if [[ -z "${CHROME_VERSION}" ]] - then - echo "Installing latest stable version" - sudo apt-get update - sudo apt-get --only-upgrade install google-chrome-stable -y - else - echo "Installing version ${CHROME_VERSION}" - wget -q "https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}_amd64.deb" - sudo dpkg -i "google-chrome-stable_${CHROME_VERSION}_amd64.deb" - fi - google-chrome --version - - # https://github.com/actions/cache/blob/main/examples.md#node---yarn - - name: Get Yarn cache directory - id: yarn-cache-dir-path - run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - - name: Cache Yarn dependencies - uses: actions/cache@v3 - with: - # Cache entire Yarn cache directory (see previous step) - path: ${{ steps.yarn-cache-dir-path.outputs.dir }} - # Cache key is hash of yarn.lock. Therefore changes to yarn.lock will invalidate cache - key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} - restore-keys: ${{ runner.os }}-yarn- - - - name: Install Yarn dependencies - run: yarn install --frozen-lockfile - - - name: Run lint - run: yarn run lint --quiet - - - name: Check for circular dependencies - run: yarn run check-circ-deps - - - name: Run build - run: yarn run build:prod - - - name: Run specs (unit tests) - run: yarn run test:headless - - # Upload code coverage report to artifact (for one version of Node only), - # so that it can be shared with the 'codecov' job (see below) - # NOTE: Angular CLI only supports code coverage for specs. See https://github.com/angular/angular-cli/issues/6286 - - name: Upload code coverage report to Artifact - uses: actions/upload-artifact@v3 - if: matrix.node-version == '18.x' - with: - name: dspace-angular coverage report - path: 'coverage/dspace-angular/lcov.info' - retention-days: 14 - - # Using docker-compose start backend using CI configuration - # and load assetstore from a cached copy - - name: Start DSpace REST Backend via Docker (for e2e tests) - run: | - docker-compose -f ./docker/docker-compose-ci.yml up -d - docker-compose -f ./docker/cli.yml -f ./docker/cli.assetstore.yml run --rm dspace-cli - docker container ls - - # Run integration tests via Cypress.io - # https://github.com/cypress-io/github-action - # (NOTE: to run these e2e tests locally, just use 'ng e2e') - - name: Run e2e tests (integration tests) - uses: cypress-io/github-action@v5 - with: - # Run tests in Chrome, headless mode (default) - browser: chrome - # Start app before running tests (will be stopped automatically after tests finish) - start: yarn run serve:ssr - # Wait for backend & frontend to be available - # NOTE: We use the 'sites' REST endpoint to also ensure the database is ready - wait-on: http://127.0.0.1:8080/server/api/core/sites, http://127.0.0.1:4000 - # Wait for 2 mins max for everything to respond - wait-on-timeout: 120 - - # Cypress always creates a video of all e2e tests (whether they succeeded or failed) - # Save those in an Artifact - - name: Upload e2e test videos to Artifacts - uses: actions/upload-artifact@v3 - if: always() - with: - name: e2e-test-videos - path: cypress/videos - - # If e2e tests fail, Cypress creates a screenshot of what happened - # Save those in an Artifact - - name: Upload e2e test failure screenshots to Artifacts - uses: actions/upload-artifact@v3 - if: failure() - with: - name: e2e-test-screenshots - path: cypress/screenshots - - - name: Stop app (in case it stays up after e2e tests) - run: | - app_pid=$(lsof -t -i:4000) - if [[ ! -z $app_pid ]]; then - echo "App was still up! (PID: $app_pid)" - kill -9 $app_pid - fi - - # Start up the app with SSR enabled (run in background) - - name: Start app in SSR (server-side rendering) mode - run: | - nohup yarn run serve:ssr & - printf 'Waiting for app to start' - until curl --output /dev/null --silent --head --fail http://127.0.0.1:4000/home; do - printf '.' - sleep 2 - done - echo "App started successfully." - - # Get homepage and verify that the tag includes "DSpace". - # If it does, then SSR is working, as this tag is created by our MetadataService. - # This step also prints entire HTML of homepage for easier debugging if grep fails. - - name: Verify SSR (server-side rendering) - run: | - result=$(wget -O- -q http://127.0.0.1:4000/home) - echo "$result" - echo "$result" | grep -oE "]*>" | grep DSpace - - - name: Stop running app - run: kill -9 $(lsof -t -i:4000) - - - name: Shutdown Docker containers - run: docker-compose -f ./docker/docker-compose-ci.yml down - - # Codecov upload is a separate job in order to allow us to restart this separate from the entire build/test - # job above. This is necessary because Codecov uploads seem to randomly fail at times. - # See https://community.codecov.com/t/upload-issues-unable-to-locate-build-via-github-actions-api/3954 - codecov: - # Must run after 'tests' job above - needs: tests - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - # Download artifacts from previous 'tests' job - - name: Download coverage artifacts - uses: actions/download-artifact@v3 - - # Now attempt upload to Codecov using its action. - # NOTE: We use a retry action to retry the Codecov upload if it fails the first time. - # - # Retry action: https://github.com/marketplace/actions/retry-action - # Codecov action: https://github.com/codecov/codecov-action - - name: Upload coverage to Codecov.io - uses: Wandalen/wretry.action@v1.0.36 - with: - action: codecov/codecov-action@v3 - # Try upload 5 times max - attempt_limit: 5 - # Run again in 30 seconds - attempt_delay: 30000 diff --git a/.github/workflows/codescan.yml b/.github/workflows/codescan.yml deleted file mode 100644 index 35a2e2d24aa..00000000000 --- a/.github/workflows/codescan.yml +++ /dev/null @@ -1,49 +0,0 @@ -# DSpace CodeQL code scanning configuration for GitHub -# https://docs.github.com/en/code-security/code-scanning -# -# NOTE: Code scanning must be run separate from our default build.yml -# because CodeQL requires a fresh build with all tests *disabled*. -name: "Code Scanning" - -# Run this code scan for all pushes / PRs to main branch. Also run once a week. -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - # Don't run if PR is only updating static documentation - paths-ignore: - - '**/*.md' - - '**/*.txt' - schedule: - - cron: "37 0 * * 1" - -jobs: - analyze: - name: Analyze Code - runs-on: ubuntu-latest - # Limit permissions of this GitHub action. Can only write to security-events - permissions: - actions: read - contents: read - security-events: write - - steps: - # https://github.com/actions/checkout - - name: Checkout repository - uses: actions/checkout@v3 - - # Initializes the CodeQL tools for scanning. - # https://github.com/github/codeql-action - - name: Initialize CodeQL - uses: github/codeql-action/init@v2 - with: - languages: javascript - - # Autobuild attempts to build any compiled languages - - name: Autobuild - uses: github/codeql-action/autobuild@v2 - - # Perform GitHub Code Scanning. - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 9a2c838d83f..00000000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,120 +0,0 @@ -# DSpace Docker image build for hub.docker.com -name: Docker images - -# Run this Build for all pushes to 'main' or maintenance branches, or tagged releases. -# Also run for PRs to ensure PR doesn't break Docker build process -on: - push: - branches: - - main - - 'dspace-**' - tags: - - 'dspace-**' - pull_request: - -permissions: - contents: read # to fetch code (actions/checkout) - -jobs: - docker: - # Ensure this job never runs on forked repos. It's only executed for 'dspace/dspace-angular' - if: github.repository == 'dspace/dspace-angular' - runs-on: ubuntu-latest - env: - # Define tags to use for Docker images based on Git tags/branches (for docker/metadata-action) - # For a new commit on default branch (main), use the literal tag 'dspace-7_x' on Docker image. - # For a new commit on other branches, use the branch name as the tag for Docker image. - # For a new tag, copy that tag name as the tag for Docker image. - IMAGE_TAGS: | - type=raw,value=dspace-7_x,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }} - type=ref,event=branch,enable=${{ !endsWith(github.ref, github.event.repository.default_branch) }} - type=ref,event=tag - # Define default tag "flavor" for docker/metadata-action per - # https://github.com/docker/metadata-action#flavor-input - # We turn off 'latest' tag by default. - TAGS_FLAVOR: | - latest=false - # Architectures / Platforms for which we will build Docker images - # If this is a PR, we ONLY build for AMD64. For PRs we only do a sanity check test to ensure Docker builds work. - # If this is NOT a PR (e.g. a tag or merge commit), also build for ARM64. - PLATFORMS: linux/amd64${{ github.event_name != 'pull_request' && ', linux/arm64' || '' }} - - steps: - # https://github.com/actions/checkout - - name: Checkout codebase - uses: actions/checkout@v3 - - # https://github.com/docker/setup-buildx-action - - name: Setup Docker Buildx - uses: docker/setup-buildx-action@v2 - - # https://github.com/docker/setup-qemu-action - - name: Set up QEMU emulation to build for multiple architectures - uses: docker/setup-qemu-action@v2 - - # https://github.com/docker/login-action - - name: Login to DockerHub - # Only login if not a PR, as PRs only trigger a Docker build and not a push - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_ACCESS_TOKEN }} - - ############################################### - # Build/Push the 'dspace/dspace-angular' image - ############################################### - # https://github.com/docker/metadata-action - # Get Metadata for docker_build step below - - name: Sync metadata (tags, labels) from GitHub to Docker for 'dspace-angular' image - id: meta_build - uses: docker/metadata-action@v4 - with: - images: dspace/dspace-angular - tags: ${{ env.IMAGE_TAGS }} - flavor: ${{ env.TAGS_FLAVOR }} - - # https://github.com/docker/build-push-action - - name: Build and push 'dspace-angular' image - id: docker_build - uses: docker/build-push-action@v3 - with: - context: . - file: ./Dockerfile - platforms: ${{ env.PLATFORMS }} - # For pull requests, we run the Docker build (to ensure no PR changes break the build), - # but we ONLY do an image push to DockerHub if it's NOT a PR - push: ${{ github.event_name != 'pull_request' }} - # Use tags / labels provided by 'docker/metadata-action' above - tags: ${{ steps.meta_build.outputs.tags }} - labels: ${{ steps.meta_build.outputs.labels }} - - ##################################################### - # Build/Push the 'dspace/dspace-angular' image ('-dist' tag) - ##################################################### - # https://github.com/docker/metadata-action - # Get Metadata for docker_build_dist step below - - name: Sync metadata (tags, labels) from GitHub to Docker for 'dspace-angular-dist' image - id: meta_build_dist - uses: docker/metadata-action@v4 - with: - images: dspace/dspace-angular - tags: ${{ env.IMAGE_TAGS }} - # As this is a "dist" image, its tags are all suffixed with "-dist". Otherwise, it uses the same - # tagging logic as the primary 'dspace/dspace-angular' image above. - flavor: ${{ env.TAGS_FLAVOR }} - suffix=-dist - - - name: Build and push 'dspace-angular-dist' image - id: docker_build_dist - uses: docker/build-push-action@v3 - with: - context: . - file: ./Dockerfile.dist - platforms: ${{ env.PLATFORMS }} - # For pull requests, we run the Docker build (to ensure no PR changes break the build), - # but we ONLY do an image push to DockerHub if it's NOT a PR - push: ${{ github.event_name != 'pull_request' }} - # Use tags / labels provided by 'docker/metadata-action' above - tags: ${{ steps.meta_build_dist.outputs.tags }} - labels: ${{ steps.meta_build_dist.outputs.labels }} diff --git a/.github/workflows/e.yml b/.github/workflows/e.yml new file mode 100644 index 00000000000..5418ea2597d --- /dev/null +++ b/.github/workflows/e.yml @@ -0,0 +1,13 @@ +name: Build + +# Run this Build for all pushes / PRs to current branch +on: [push, pull_request] + +jobs: + - name: Clear Cache + steps: + uses: actions/cache@v2 + with: + path: path/to/cache # Specify the path to the cache you want to clear + key: ${{ runner.os }}-my-cache-key # Specify the cache key + action: delete diff --git a/.github/workflows/issue_opened.yml b/.github/workflows/issue_opened.yml deleted file mode 100644 index b4436dca3aa..00000000000 --- a/.github/workflows/issue_opened.yml +++ /dev/null @@ -1,26 +0,0 @@ -# This workflow runs whenever a new issue is created -name: Issue opened - -on: - issues: - types: [opened] - -permissions: {} -jobs: - automation: - runs-on: ubuntu-latest - steps: - # Add the new issue to a project board, if it needs triage - # See https://github.com/actions/add-to-project - - name: Add issue to triage board - # Only add to project board if issue is flagged as "needs triage" or has no labels - # NOTE: By default we flag new issues as "needs triage" in our issue template - if: (contains(github.event.issue.labels.*.name, 'needs triage') || join(github.event.issue.labels.*.name) == '') - uses: actions/add-to-project@v0.5.0 - # Note, the authentication token below is an ORG level Secret. - # It must be created/recreated manually via a personal access token with admin:org, project, public_repo permissions - # See: https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#permissions-for-the-github_token - # This is necessary because the "DSpace Backlog" project is an org level project (i.e. not repo specific) - with: - github-token: ${{ secrets.TRIAGE_PROJECT_TOKEN }} - project-url: https://github.com/orgs/DSpace/projects/24 diff --git a/.github/workflows/label_merge_conflicts.yml b/.github/workflows/label_merge_conflicts.yml deleted file mode 100644 index c1396b6f45c..00000000000 --- a/.github/workflows/label_merge_conflicts.yml +++ /dev/null @@ -1,36 +0,0 @@ -# This workflow checks open PRs for merge conflicts and labels them when conflicts are found -name: Check for merge conflicts - -# Run whenever the "main" branch is updated -# NOTE: This means merge conflicts are only checked for when a PR is merged to main. -on: - push: - branches: [ main ] - # So that the `conflict_label_name` is removed if conflicts are resolved, - # we allow this to run for `pull_request_target` so that github secrets are available. - pull_request_target: - types: [ synchronize ] - -permissions: {} - -jobs: - triage: - # Ensure this job never runs on forked repos. It's only executed for 'dspace/dspace-angular' - if: github.repository == 'dspace/dspace-angular' - runs-on: ubuntu-latest - permissions: - pull-requests: write - steps: - # See: https://github.com/prince-chrismc/label-merge-conflicts-action - - name: Auto-label PRs with merge conflicts - uses: prince-chrismc/label-merge-conflicts-action@v3 - # Add "merge conflict" label if a merge conflict is detected. Remove it when resolved. - # Note, the authentication token is created automatically - # See: https://docs.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token - with: - conflict_label_name: 'merge conflict' - github_token: ${{ secrets.GITHUB_TOKEN }} - conflict_comment: | - Hi @${author}, - Conflicts have been detected against the base branch. - Please [resolve these conflicts](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/addressing-merge-conflicts/about-merge-conflicts) as soon as you can. Thanks! \ No newline at end of file