file scoped namespace and other csharp features #286
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Web | |
env: | |
DOTNET_CLI_TELEMETRY_OPTOUT: 1 | |
IS_BUILD_SERVER: true # Needed by spa testing | |
# SENTRY_LOG_LEVEL: "debug" | |
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
branches: | |
- main | |
paths: | |
- 'src/NuGetTrends.Web/**' | |
- 'src/NuGetTrends.Data/**' | |
- 'src/Directory.Build.props' | |
- '**/web-workflow.yml' | |
pull_request: | |
paths: | |
- 'src/NuGetTrends.Web/**' | |
- 'src/NuGetTrends.Data/**' | |
- 'src/Directory.Build.props' | |
- '**/web-workflow.yml' | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
DOTNET_CLI_TELEMETRY_OPTOUT: 1 | |
DOTNET_NOLOGO: 1 | |
DOTNET_MULTILEVEL_LOOKUP: 1 | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Prepare Docker | |
id: docker-prep | |
run: | | |
DOCKER_IMAGE=nugettrends/nugettrends.web | |
VERSION=noop | |
ENVIRONMENT=test | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
VERSION=${GITHUB_REF#refs/tags/} | |
ENVIRONMENT=prod | |
elif [[ $GITHUB_REF == refs/heads/main ]]; then | |
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') | |
fi | |
TAGS="${DOCKER_IMAGE}:${VERSION}" | |
if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then | |
MINOR=${VERSION%.*} | |
MAJOR=${MINOR%.*} | |
TAGS="$TAGS,${DOCKER_IMAGE}:${MINOR},${DOCKER_IMAGE}:${MAJOR},${DOCKER_IMAGE}:latest" | |
elif [ "${{ github.event_name }}" = "push" ]; then | |
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}" | |
fi | |
echo ::set-output name=environment::${ENVIRONMENT} | |
echo ::set-output name=version::${VERSION} | |
echo ::set-output name=tags::${TAGS} | |
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ') | |
- name: Docker values debug | |
run: | | |
echo ${{ steps.docker-prep.outputs.environment }} | |
echo ${{ steps.docker-prep.outputs.version }} | |
echo ${{ steps.docker-prep.outputs.tags }} | |
echo ${{ steps.docker-prep.outputs.created }} | |
- name: Install Node | |
uses: actions/setup-node@v1 | |
with: | |
node-version: '18.12.1' | |
- name: Get yarn cache directory path | |
id: yarn-cache-dir-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Cache node modules | |
uses: actions/cache@v2 | |
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
${{ runner.os }}- | |
- name: Install Angular CLI | |
run: npm install -g @angular/[email protected] | |
- name: Install Yarn | |
run: npm install -g yarn | |
- name: Test/print Angular CLI versoin | |
run: ng version | |
- name: 'Install SPA packages' | |
run: yarn install | |
working-directory: src/NuGetTrends.Web/Portal | |
# TODO: Enable again when we migrate to ESLint | |
# - name: 'SPA lint' | |
# run: yarn run lint | |
# working-directory: src/NuGetTrends.Web/Portal | |
- name: 'SPA test' | |
run: yarn run test-cc | |
working-directory: src/NuGetTrends.Web/Portal | |
- name: 'SPA prod build' | |
# Angular runs a prod build by default | |
run: yarn run build | |
working-directory: src/NuGetTrends.Web/Portal | |
- name: Replace SPA path on coverage file (Hack codecov) # https://community.codecov.io/t/looking-for-assistance-with-path-fixing/1669/9 | |
run: sed -i 's/SF:/SF:src\/NuGetTrends.Web\/Portal\//g' src/NuGetTrends.Web/Portal/coverage/lcov.info | |
- name: Upload SPA coverage report to Codecov | |
uses: codecov/codecov-action@v3 | |
- name: Web Build | |
run: dotnet build -c Release | |
env: | |
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} | |
working-directory: src/NuGetTrends.Web/ | |
- name: Web Publish | |
run: dotnet publish -c Release -o publish --no-build | |
working-directory: src/NuGetTrends.Web/ | |
- uses: docker/setup-qemu-action@v1 | |
- uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
id: docker_build | |
with: | |
context: ./src/NuGetTrends.Web | |
file: ./src/NuGetTrends.Web/Dockerfile | |
build-args: | | |
ENVIRONMENT=${{ steps.docker-prep.outputs.environment }} | |
VERSION=${{ steps.docker-prep.outputs.version }} | |
platforms: linux/amd64 | |
push: ${{ github.event_name != 'pull_request' }} | |
tags: ${{ steps.docker-prep.outputs.tags }} | |
labels: | | |
org.opencontainers.image.created=${{ steps.docker-prep.outputs.created }} | |
org.opencontainers.image.source=${{ github.repositoryUrl }} | |
org.opencontainers.image.version=${{ steps.docker-prep.outputs.version }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
org.opencontainers.image.licenses=${{ github.event.repository.license.name }} |