aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/test-and-deploy.yml
blob: a94273506fca369828f8da1343c7e4421e66aea6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
name: Compiler Explorer

on: [push, pull_request]

jobs:
  build-and-test:
    if: github.repository_owner != 'compiler-explorer'
    runs-on: ubuntu-20.04

    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Use Node.js 14.x
        uses: actions/setup-node@v1
        with:
          node-version: 14.x
      - name: Get npm cache directory
        id: npm-cache
        run: |
          echo "::set-output name=dir::$(npm config get cache)"
      - uses: actions/cache@v1
        with:
          path: ${{ steps.npm-cache.outputs.dir }}
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-
      - name: Install prerequisites
        run: make prereqs
      - name: Build and test
        run: |
          npm run lint
          npm run ci-test
      - name: Code coverage
        run: npm run codecov

  build-dist-and-deploy:
    if: github.repository_owner == 'compiler-explorer'
    runs-on: ubuntu-20.04

    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - name: Use Node.js 14.x
        uses: actions/setup-node@v1
        with:
          node-version: 14.x
      - name: TEST
        run: |
          which npx
          npx --version
      - name: Get npm cache directory
        id: npm-cache
        run: |
          echo "::set-output name=dir::$(npm config get cache)"
      - uses: actions/cache@v1
        with:
          path: ${{ steps.npm-cache.outputs.dir }}
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-
      - name: Install prerequisites
        run: make prereqs
      - name: Build and test
        run: |
          npm run lint
          npm run ci-test
      - name: Code coverage
        run: npm run codecov
      - name: Build distribution
        id: build_dist
        run: |
          export SENTRY_AUTH_TOKEN='${{ secrets.SENTRY_AUTH_TOKEN }}'
          export SENTRY_DSN='${{ secrets.SENTRY_DSN }}'
          export SENTRY_ORG=compiler-explorer
          export SENTRY_PROJECT=compiler-explorer
          make changelog
          make policies
          make -j$(nproc) gh-dist NPM_FLAGS="--no-audit"
      - name: Deploy
        uses: jakejarvis/s3-sync-action@master
        with:
          args: --acl public-read --follow-symlinks
        env:
          AWS_S3_BUCKET: compiler-explorer
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          SOURCE_DIR: out/dist-bin
          DEST_DIR: dist/gh/${{ steps.build_dist.outputs.branch }}
      - name: Tag the commit
        uses: tvdias/github-tagger@v0.0.2
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          tag: gh-${{ github.run_number }}